specs.proto 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. syntax = "proto3";
  2. package docker.swarmkit.v1;
  3. import "github.com/docker/swarmkit/api/types.proto";
  4. import "gogoproto/gogo.proto";
  5. import "google/protobuf/duration.proto";
  6. import "google/protobuf/any.proto";
  7. import "google/protobuf/wrappers.proto";
  8. // Specs are container objects for user provided input. All creations and
  9. // updates are done through spec types. As a convention, user input from a spec
  10. // is never touched in created objects. This allows one to verify that the
  11. // users intent has not been modified.
  12. //
  13. // Put differently, spec types can be said to represent the desired state of
  14. // the system. In situations where modifications need to be made to a
  15. // particular component, API objects will either contain a copy of the spec
  16. // component or a different representation to reflect allocation or resolution.
  17. message NodeSpec {
  18. Annotations annotations = 1 [(gogoproto.nullable) = false];
  19. enum Membership {
  20. option (gogoproto.goproto_enum_prefix) = false;
  21. PENDING = 0 [(gogoproto.enumvalue_customname) = "NodeMembershipPending"];
  22. ACCEPTED = 1 [(gogoproto.enumvalue_customname) = "NodeMembershipAccepted"];
  23. }
  24. enum Availability {
  25. option (gogoproto.goproto_enum_prefix) = false;
  26. // Active nodes.
  27. ACTIVE = 0 [(gogoproto.enumvalue_customname) = "NodeAvailabilityActive"];
  28. // Paused nodes won't be considered by the scheduler, preventing any
  29. // further task to run on them.
  30. PAUSE = 1 [(gogoproto.enumvalue_customname) = "NodeAvailabilityPause"];
  31. // Drained nodes are paused and any task already running on them will
  32. // be evicted.
  33. DRAIN = 2 [(gogoproto.enumvalue_customname) = "NodeAvailabilityDrain"];
  34. }
  35. // DesiredRole defines the role the node should have.
  36. NodeRole desired_role = 2;
  37. // Membership controls the admission of the node into the cluster.
  38. Membership membership = 3;
  39. // Availability allows a user to control the current scheduling status of a
  40. // node.
  41. Availability availability = 4;
  42. }
  43. // ServiceSpec defines the properties of a service.
  44. //
  45. // A service instructs the cluster in orchestrating repeated instances of a
  46. // template, implemented as tasks. Based on the number of instances, scheduling
  47. // strategy and restart policy, a number of application-level behaviors can be
  48. // defined.
  49. message ServiceSpec {
  50. Annotations annotations = 1 [(gogoproto.nullable) = false];
  51. // Task defines the task template this service will spawn.
  52. TaskSpec task = 2 [(gogoproto.nullable) = false];
  53. oneof mode {
  54. ReplicatedService replicated = 3;
  55. GlobalService global = 4;
  56. }
  57. // Update contains settings which affect updates.
  58. UpdateConfig update = 6;
  59. // Rollback contains settings which affect rollbacks of updates.
  60. UpdateConfig rollback = 9;
  61. // ServiceSpec.Networks has been deprecated and is replaced by
  62. // Networks field in Task (TaskSpec.Networks).
  63. // This field (ServiceSpec.Networks) is kept for compatibility.
  64. // In case TaskSpec.Networks does not exist, ServiceSpec.Networks
  65. // is still honored if it exists.
  66. repeated NetworkAttachmentConfig networks = 7 [deprecated=true];
  67. // Service endpoint specifies the user provided configuration
  68. // to properly discover and load balance a service.
  69. EndpointSpec endpoint = 8;
  70. }
  71. // ReplicatedService sets the reconciliation target to certain number of replicas.
  72. message ReplicatedService {
  73. uint64 replicas = 1;
  74. }
  75. // GlobalService represents global service.
  76. message GlobalService {
  77. // Empty message for now.
  78. }
  79. message TaskSpec {
  80. oneof runtime {
  81. NetworkAttachmentSpec attachment = 8;
  82. ContainerSpec container = 1;
  83. GenericRuntimeSpec generic = 10;
  84. }
  85. // Resource requirements for the container.
  86. ResourceRequirements resources = 2;
  87. // RestartPolicy specifies what to do when a task fails or finishes.
  88. RestartPolicy restart = 4;
  89. // Placement specifies node selection constraints
  90. Placement placement = 5;
  91. // LogDriver specifies the log driver to use for the task. Any runtime will
  92. // direct logs into the specified driver for the duration of the task.
  93. Driver log_driver = 6;
  94. // Networks specifies the list of network attachment
  95. // configurations (which specify the network and per-network
  96. // aliases) that this task spec is bound to.
  97. repeated NetworkAttachmentConfig networks = 7;
  98. // ForceUpdate is a counter that triggers an update even if no relevant
  99. // parameters have been changed. We do this to allow forced restarts
  100. // using the same reconciliation-based mechanism that performs rolling
  101. // updates.
  102. uint64 force_update = 9;
  103. // ResourceReferences provides a generic way to specify resources that
  104. // are used by this task, and should be sent down to agents along with
  105. // the task. Inside the runtime field there may be more specific
  106. // information about how to use the resource, but ResourceReferences
  107. // establishes the relationship at the store level, and instructs the
  108. // dispatcher to send the related objects.
  109. //
  110. // ResourceReferences is a list of ResourceReferences used by the task.
  111. repeated ResourceReference resource_references = 11 [(gogoproto.nullable) = false];
  112. }
  113. message ResourceReference {
  114. string resource_id = 1;
  115. ResourceType resource_type = 2;
  116. }
  117. message GenericRuntimeSpec {
  118. string kind = 1;
  119. google.protobuf.Any payload = 2;
  120. }
  121. // NetworkAttachmentSpec specifies runtime parameters required to attach
  122. // a container to a network.
  123. message NetworkAttachmentSpec {
  124. // ContainerID specifies a unique ID of the container for which
  125. // this attachment is for.
  126. string container_id = 1;
  127. }
  128. // Container specifies runtime parameters for a container.
  129. message ContainerSpec {
  130. // image defines the image reference, as specified in the
  131. // distribution/reference package. This may include a registry host, name,
  132. // tag or digest.
  133. //
  134. // The field will be directly passed to the engine pulling. Well-behaved
  135. // service definitions will used immutable references, either through tags
  136. // that don't change or verifiable digests.
  137. string image = 1;
  138. // Labels defines labels to be added to the container at creation time. If
  139. // collisions with system labels occur, these labels will be overridden.
  140. //
  141. // This field *must* remain compatible with the Labels field of
  142. // Annotations.
  143. map<string, string> labels = 2;
  144. // Command to run the the container. The first element is a path to the
  145. // executable and the following elements are treated as arguments.
  146. //
  147. // If command is empty, execution will fall back to the image's entrypoint.
  148. //
  149. // Command should only be used when overriding entrypoint.
  150. repeated string command = 3;
  151. // Args specifies arguments provided to the image's entrypoint.
  152. //
  153. // If Command and Args are provided, Args will be appended to Command.
  154. repeated string args = 4;
  155. // Hostname specifies the hostname that will be set on containers created by docker swarm.
  156. // All containers for a given service will have the same hostname
  157. string hostname = 14;
  158. // Env specifies the environment variables for the container in NAME=VALUE
  159. // format. These must be compliant with [IEEE Std
  160. // 1003.1-2001](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html).
  161. repeated string env = 5;
  162. // Dir defines the working directory to set for the container process.
  163. string dir = 6;
  164. // User specifies the user that should be employed to run the container.
  165. //
  166. // Note that the primary group may be specified by appending the group name
  167. // or id to the user name, separated by a `:`. This syntax is
  168. // `<user>:<group>`.
  169. string user = 7;
  170. // Groups specifies supplementary groups available to the user.
  171. repeated string groups = 11;
  172. // Privileges specifies security configuration/permissions.
  173. Privileges privileges = 22;
  174. // Init declares that a custom init will be running inside the container, if null, use the daemon's configured settings
  175. google.protobuf.BoolValue init = 23;
  176. // TTY declares that a TTY should be attached to the standard streams,
  177. // including stdin if it is still open.
  178. bool tty = 13 [(gogoproto.customname) = "TTY"];
  179. // OpenStdin declares that the standard input (stdin) should be open.
  180. bool open_stdin = 18;
  181. // ReadOnly declares that the container root filesystem is read-only.
  182. // This only impacts the root filesystem, not additional mounts (including
  183. // tmpfs). For additional mounts that are not part of the initial rootfs,
  184. // they will be decided by the modes passed in the mount definition.
  185. bool read_only = 19;
  186. // StopSignal defines the signal to stop the container.
  187. string stop_signal = 20;
  188. repeated Mount mounts = 8 [(gogoproto.nullable) = false];
  189. // StopGracePeriod the grace period for stopping the container before
  190. // forcefully killing the container.
  191. // Note: Can't use stdduration here because this needs to be nullable.
  192. google.protobuf.Duration stop_grace_period = 9;
  193. // PullOptions allows one to parameterize an image pull.
  194. message PullOptions {
  195. // RegistryAuth is the registry auth token obtained from the client, required
  196. // to pull private images. This is the unmodified JSON used as part of
  197. // the `X-Registry-Auth` header.
  198. // TODO(nishanttotla): This field will later be deprecated
  199. string registry_auth = 64;
  200. }
  201. // PullOptions parameterize the behavior of image pulls.
  202. PullOptions pull_options = 10;
  203. // SecretReference contains references to zero or more secrets that
  204. // will be exposed to the container.
  205. repeated SecretReference secrets = 12;
  206. // ConfigReference contains references to zero or more configs that
  207. // will be exposed to the container.
  208. repeated ConfigReference configs = 21;
  209. // Hosts allow additional entries to be specified in /etc/hosts
  210. // that associates IP addresses with hostnames.
  211. // Detailed documentation is available in:
  212. // http://man7.org/linux/man-pages/man5/hosts.5.html
  213. // IP_address canonical_hostname [aliases...]
  214. //
  215. // The format of the Hosts in swarmkit follows the same as
  216. // above.
  217. // This is different from `docker run --add-host <hostname>:<ip>`
  218. // where format is `<hostname>:<ip>`
  219. repeated string hosts = 17;
  220. // DNSConfig specifies DNS related configurations in resolver configuration file (resolv.conf)
  221. // Detailed documentation is available in:
  222. // http://man7.org/linux/man-pages/man5/resolv.conf.5.html
  223. // TODO: domain is not supported yet
  224. message DNSConfig {
  225. // Nameservers specifies the IP addresses of the name servers
  226. repeated string nameservers = 1;
  227. // Search specifies the search list for host-name lookup
  228. repeated string search = 2;
  229. // Options allows certain internal resolver variables to be modified
  230. repeated string options = 3;
  231. }
  232. // DNSConfig allows one to specify DNS related configuration in resolv.conf
  233. DNSConfig dns_config = 15 [(gogoproto.customname) = "DNSConfig"];
  234. // Healthcheck describes how to check the container is healthy. If the
  235. // container is considered unhealthy, it will be destroyed, its creating
  236. // task will exit and a new task will be rescheduled elsewhere. A container
  237. // is considered unhealthy after `Retries` number of consecutive failures.
  238. HealthConfig healthcheck = 16;
  239. enum Isolation {
  240. option (gogoproto.goproto_enum_prefix) = false;
  241. // ISOLATION_DEFAULT uses whatever default value from the container runtime
  242. ISOLATION_DEFAULT = 0 [(gogoproto.enumvalue_customname) = "ContainerIsolationDefault"];
  243. // ISOLATION_PROCESS forces windows container isolation
  244. ISOLATION_PROCESS = 1 [(gogoproto.enumvalue_customname) = "ContainerIsolationProcess"];
  245. // ISOLATION_HYPERV forces Hyper-V isolation
  246. ISOLATION_HYPERV = 2 [(gogoproto.enumvalue_customname) = "ContainerIsolationHyperV"];
  247. }
  248. // Isolation defines the isolation level for windows containers (default, process, hyperv).
  249. // Runtimes that don't support it ignore that field
  250. Isolation isolation = 24;
  251. // PidsLimit prevents from OS resource damage by applications inside the container
  252. // using fork bomb attack.
  253. int64 pidsLimit = 25;
  254. }
  255. // EndpointSpec defines the properties that can be configured to
  256. // access and loadbalance the service.
  257. message EndpointSpec {
  258. // ResolutionMode specifies the mode of resolution to use for
  259. // internal loadbalancing between tasks which are all within
  260. // the cluster. This is sometimes calls east-west data path.
  261. enum ResolutionMode {
  262. option (gogoproto.goproto_enum_prefix) = false;
  263. // VIP resolution mode specifies that the
  264. // service resolves to a logical IP and the requests
  265. // are sent to that logical IP. Packets hitting that
  266. // logical IP are load balanced to a chosen backend.
  267. VIP = 0 [(gogoproto.enumvalue_customname) = "ResolutionModeVirtualIP"];
  268. // DNSRR resolution mode specifies that the
  269. // service directly gets resolved to one of the
  270. // backend IP and the client directly initiates a
  271. // request towards the actual backend. This requires
  272. // that the client does not cache the DNS responses
  273. // when the DNS response TTL is 0.
  274. DNSRR = 1 [(gogoproto.enumvalue_customname) = "ResolutionModeDNSRoundRobin"];
  275. }
  276. ResolutionMode mode = 1;
  277. // List of exposed ports that this service is accessible from
  278. // external to the cluster.
  279. repeated PortConfig ports = 2;
  280. }
  281. // NetworkSpec specifies user defined network parameters.
  282. message NetworkSpec {
  283. Annotations annotations = 1 [(gogoproto.nullable) = false];
  284. // DriverConfig specific configuration consumed by the network driver.
  285. Driver driver_config = 2;
  286. // IPv6Enabled enables support for IPv6 on the network.
  287. bool ipv6_enabled = 3;
  288. // internal restricts external access to the network. This may be
  289. // accomplished by disabling the default gateway or through other means.
  290. bool internal = 4;
  291. IPAMOptions ipam = 5 [(gogoproto.customname) = "IPAM"];
  292. // Attachable allows external(to swarm) entities to manually
  293. // attach to this network. With this flag enabled, external
  294. // entities such as containers running in an worker node in
  295. // the cluster can manually attach to this network and access
  296. // the services attached to this network. If this flag is not
  297. // enabled(default case) no manual attachment to this network
  298. // can happen.
  299. bool attachable = 6;
  300. // Ingress indicates this network will provide the routing-mesh.
  301. // In older versions, the network providing the routing mesh was
  302. // swarm internally created only and it was identified by the name
  303. // "ingress" and the label "com.docker.swarm.internal": "true".
  304. bool ingress = 7;
  305. // ConfigFrom is the source of the configuration for this network.
  306. oneof config_from {
  307. // Network is the name of a network that provides the network
  308. // specific configuration for this network, locally on the node
  309. // where this network is being plumbed.
  310. string network = 8;
  311. }
  312. }
  313. // ClusterSpec specifies global cluster settings.
  314. message ClusterSpec {
  315. Annotations annotations = 1 [(gogoproto.nullable) = false];
  316. // DEPRECATED: AcceptancePolicy defines the certificate issuance policy.
  317. // Acceptance policy is no longer customizable, and secrets have been
  318. // replaced with join tokens.
  319. AcceptancePolicy acceptance_policy = 2 [deprecated=true, (gogoproto.nullable) = false];
  320. // Orchestration defines cluster-level orchestration settings.
  321. OrchestrationConfig orchestration = 3 [(gogoproto.nullable) = false];
  322. // Raft defines the cluster's raft settings.
  323. RaftConfig raft = 4 [(gogoproto.nullable) = false];
  324. // Dispatcher defines cluster-level dispatcher settings.
  325. DispatcherConfig dispatcher = 5 [(gogoproto.nullable) = false];
  326. // CAConfig defines cluster-level certificate authority settings.
  327. CAConfig ca_config = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "CAConfig"];
  328. // TaskDefaults specifies the default values to use for task creation.
  329. TaskDefaults task_defaults = 7 [(gogoproto.nullable) = false];
  330. // EncryptionConfig defines the cluster's encryption settings.
  331. EncryptionConfig encryption_config = 8 [(gogoproto.nullable) = false];
  332. }
  333. // SecretSpec specifies a user-provided secret.
  334. message SecretSpec {
  335. Annotations annotations = 1 [(gogoproto.nullable) = false];
  336. // Data is the secret payload - the maximum size is 500KB (that is, 500*1024 bytes)
  337. bytes data = 2;
  338. // Templating controls whether and how to evaluate the secret payload as
  339. // a template. If it is not set, no templating is used.
  340. //
  341. // The currently recognized values are:
  342. // - golang: Go templating
  343. Driver templating = 3;
  344. // Driver is the the secret driver that is used to store the specified secret
  345. Driver driver = 4;
  346. }
  347. // ConfigSpec specifies user-provided configuration files.
  348. message ConfigSpec {
  349. Annotations annotations = 1 [(gogoproto.nullable) = false];
  350. // Data is the config payload - the maximum size is 500KB (that is, 500*1024 bytes)
  351. // TODO(aaronl): Do we want to revise this to include multiple payloads in a single
  352. // ConfigSpec? Define this to be a tar? etc...
  353. bytes data = 2;
  354. // Templating controls whether and how to evaluate the secret payload as
  355. // a template. If it is not set, no templating is used.
  356. //
  357. // The currently recognized values are:
  358. // - golang: Go templating
  359. Driver templating = 3;
  360. }