specs.proto 13 KB

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