specs.proto 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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. ReplicatedJob replicated_job = 10;
  57. GlobalJob global_job = 11;
  58. }
  59. // Update contains settings which affect updates.
  60. UpdateConfig update = 6;
  61. // Rollback contains settings which affect rollbacks of updates.
  62. UpdateConfig rollback = 9;
  63. // ServiceSpec.Networks has been deprecated and is replaced by
  64. // Networks field in Task (TaskSpec.Networks).
  65. // This field (ServiceSpec.Networks) is kept for compatibility.
  66. // In case TaskSpec.Networks does not exist, ServiceSpec.Networks
  67. // is still honored if it exists.
  68. repeated NetworkAttachmentConfig networks = 7 [deprecated=true];
  69. // Service endpoint specifies the user provided configuration
  70. // to properly discover and load balance a service.
  71. EndpointSpec endpoint = 8;
  72. }
  73. // ReplicatedService sets the reconciliation target to certain number of replicas.
  74. message ReplicatedService {
  75. uint64 replicas = 1;
  76. }
  77. // GlobalService represents global service.
  78. message GlobalService {
  79. // Empty message for now.
  80. }
  81. // ReplicatedJob is a certain type of one-off job which executes many Tasks in
  82. // parallel until the specified number of Tasks have succeeded.
  83. message ReplicatedJob {
  84. // MaxConcurrent indicates the maximum number of Tasks that should be
  85. // executing simultaneously at any given time.
  86. uint64 max_concurrent = 1;
  87. // TotalCompletions sets the total number of Tasks desired to run to
  88. // completion. This is also the absolute maximum number of Tasks that will
  89. // be executed in parallel. That is, if this number is smaller than
  90. // MaxConcurrent, only this many replicas will run.
  91. uint64 total_completions = 2;
  92. }
  93. // GlobalJob is a type of one-off job which executes one Task on every node
  94. // matching the service's placement constraints.
  95. message GlobalJob {
  96. // Empty message for now.
  97. }
  98. message TaskSpec {
  99. oneof runtime {
  100. NetworkAttachmentSpec attachment = 8;
  101. ContainerSpec container = 1;
  102. GenericRuntimeSpec generic = 10;
  103. }
  104. // Resource requirements for the container.
  105. ResourceRequirements resources = 2;
  106. // RestartPolicy specifies what to do when a task fails or finishes.
  107. RestartPolicy restart = 4;
  108. // Placement specifies node selection constraints
  109. Placement placement = 5;
  110. // LogDriver specifies the log driver to use for the task. Any runtime will
  111. // direct logs into the specified driver for the duration of the task.
  112. Driver log_driver = 6;
  113. // Networks specifies the list of network attachment
  114. // configurations (which specify the network and per-network
  115. // aliases) that this task spec is bound to.
  116. repeated NetworkAttachmentConfig networks = 7;
  117. // ForceUpdate is a counter that triggers an update even if no relevant
  118. // parameters have been changed. We do this to allow forced restarts
  119. // using the same reconciliation-based mechanism that performs rolling
  120. // updates.
  121. uint64 force_update = 9;
  122. // ResourceReferences provides a generic way to specify resources that
  123. // are used by this task, and should be sent down to agents along with
  124. // the task. Inside the runtime field there may be more specific
  125. // information about how to use the resource, but ResourceReferences
  126. // establishes the relationship at the store level, and instructs the
  127. // dispatcher to send the related objects.
  128. //
  129. // ResourceReferences is a list of ResourceReferences used by the task.
  130. repeated ResourceReference resource_references = 11 [(gogoproto.nullable) = false];
  131. }
  132. message ResourceReference {
  133. string resource_id = 1;
  134. ResourceType resource_type = 2;
  135. }
  136. message GenericRuntimeSpec {
  137. string kind = 1;
  138. google.protobuf.Any payload = 2;
  139. }
  140. // NetworkAttachmentSpec specifies runtime parameters required to attach
  141. // a container to a network.
  142. message NetworkAttachmentSpec {
  143. // ContainerID specifies a unique ID of the container for which
  144. // this attachment is for.
  145. string container_id = 1;
  146. }
  147. // Container specifies runtime parameters for a container.
  148. message ContainerSpec {
  149. // image defines the image reference, as specified in the
  150. // distribution/reference package. This may include a registry host, name,
  151. // tag or digest.
  152. //
  153. // The field will be directly passed to the engine pulling. Well-behaved
  154. // service definitions will used immutable references, either through tags
  155. // that don't change or verifiable digests.
  156. string image = 1;
  157. // Labels defines labels to be added to the container at creation time. If
  158. // collisions with system labels occur, these labels will be overridden.
  159. //
  160. // This field *must* remain compatible with the Labels field of
  161. // Annotations.
  162. map<string, string> labels = 2;
  163. // Command to run the the container. The first element is a path to the
  164. // executable and the following elements are treated as arguments.
  165. //
  166. // If command is empty, execution will fall back to the image's entrypoint.
  167. //
  168. // Command should only be used when overriding entrypoint.
  169. repeated string command = 3;
  170. // Args specifies arguments provided to the image's entrypoint.
  171. //
  172. // If Command and Args are provided, Args will be appended to Command.
  173. repeated string args = 4;
  174. // Hostname specifies the hostname that will be set on containers created by docker swarm.
  175. // All containers for a given service will have the same hostname
  176. string hostname = 14;
  177. // Env specifies the environment variables for the container in NAME=VALUE
  178. // format. These must be compliant with [IEEE Std
  179. // 1003.1-2001](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html).
  180. repeated string env = 5;
  181. // Dir defines the working directory to set for the container process.
  182. string dir = 6;
  183. // User specifies the user that should be employed to run the container.
  184. //
  185. // Note that the primary group may be specified by appending the group name
  186. // or id to the user name, separated by a `:`. This syntax is
  187. // `<user>:<group>`.
  188. string user = 7;
  189. // Groups specifies supplementary groups available to the user.
  190. repeated string groups = 11;
  191. // Privileges specifies security configuration/permissions.
  192. Privileges privileges = 22;
  193. // Init declares that a custom init will be running inside the container, if null, use the daemon's configured settings
  194. google.protobuf.BoolValue init = 23;
  195. // TTY declares that a TTY should be attached to the standard streams,
  196. // including stdin if it is still open.
  197. bool tty = 13 [(gogoproto.customname) = "TTY"];
  198. // OpenStdin declares that the standard input (stdin) should be open.
  199. bool open_stdin = 18;
  200. // ReadOnly declares that the container root filesystem is read-only.
  201. // This only impacts the root filesystem, not additional mounts (including
  202. // tmpfs). For additional mounts that are not part of the initial rootfs,
  203. // they will be decided by the modes passed in the mount definition.
  204. bool read_only = 19;
  205. // StopSignal defines the signal to stop the container.
  206. string stop_signal = 20;
  207. repeated Mount mounts = 8 [(gogoproto.nullable) = false];
  208. // StopGracePeriod the grace period for stopping the container before
  209. // forcefully killing the container.
  210. // Note: Can't use stdduration here because this needs to be nullable.
  211. google.protobuf.Duration stop_grace_period = 9;
  212. // PullOptions allows one to parameterize an image pull.
  213. message PullOptions {
  214. // RegistryAuth is the registry auth token obtained from the client, required
  215. // to pull private images. This is the unmodified JSON used as part of
  216. // the `X-Registry-Auth` header.
  217. // TODO(nishanttotla): This field will later be deprecated
  218. string registry_auth = 64;
  219. }
  220. // PullOptions parameterize the behavior of image pulls.
  221. PullOptions pull_options = 10;
  222. // SecretReference contains references to zero or more secrets that
  223. // will be exposed to the container.
  224. repeated SecretReference secrets = 12;
  225. // ConfigReference contains references to zero or more configs that
  226. // will be exposed to the container.
  227. repeated ConfigReference configs = 21;
  228. // Hosts allow additional entries to be specified in /etc/hosts
  229. // that associates IP addresses with hostnames.
  230. // Detailed documentation is available in:
  231. // http://man7.org/linux/man-pages/man5/hosts.5.html
  232. // IP_address canonical_hostname [aliases...]
  233. //
  234. // The format of the Hosts in swarmkit follows the same as
  235. // above.
  236. // This is different from `docker run --add-host <hostname>:<ip>`
  237. // where format is `<hostname>:<ip>`
  238. repeated string hosts = 17;
  239. // DNSConfig specifies DNS related configurations in resolver configuration file (resolv.conf)
  240. // Detailed documentation is available in:
  241. // http://man7.org/linux/man-pages/man5/resolv.conf.5.html
  242. // TODO: domain is not supported yet
  243. message DNSConfig {
  244. // Nameservers specifies the IP addresses of the name servers
  245. repeated string nameservers = 1;
  246. // Search specifies the search list for host-name lookup
  247. repeated string search = 2;
  248. // Options allows certain internal resolver variables to be modified
  249. repeated string options = 3;
  250. }
  251. // DNSConfig allows one to specify DNS related configuration in resolv.conf
  252. DNSConfig dns_config = 15 [(gogoproto.customname) = "DNSConfig"];
  253. // Healthcheck describes how to check the container is healthy. If the
  254. // container is considered unhealthy, it will be destroyed, its creating
  255. // task will exit and a new task will be rescheduled elsewhere. A container
  256. // is considered unhealthy after `Retries` number of consecutive failures.
  257. HealthConfig healthcheck = 16;
  258. enum Isolation {
  259. option (gogoproto.goproto_enum_prefix) = false;
  260. // ISOLATION_DEFAULT uses whatever default value from the container runtime
  261. ISOLATION_DEFAULT = 0 [(gogoproto.enumvalue_customname) = "ContainerIsolationDefault"];
  262. // ISOLATION_PROCESS forces windows container isolation
  263. ISOLATION_PROCESS = 1 [(gogoproto.enumvalue_customname) = "ContainerIsolationProcess"];
  264. // ISOLATION_HYPERV forces Hyper-V isolation
  265. ISOLATION_HYPERV = 2 [(gogoproto.enumvalue_customname) = "ContainerIsolationHyperV"];
  266. }
  267. // Isolation defines the isolation level for windows containers (default, process, hyperv).
  268. // Runtimes that don't support it ignore that field
  269. Isolation isolation = 24;
  270. // PidsLimit prevents from OS resource damage by applications inside the container
  271. // using fork bomb attack.
  272. int64 pidsLimit = 25;
  273. // Sysctls sets namespaced kernel parameters (sysctls) in the container. This
  274. // option is equivalent to passing --sysctl to docker run.
  275. //
  276. // Note that while options are subject to the same restrictions as arguments
  277. // passed to the --sysctl flag on docker run, those options are not further
  278. // validated to ensure that they are safe or sensible in a clustered
  279. // environment.
  280. //
  281. // Additionally, sysctls are not validated for support in the underlying
  282. // daemon. For information about supported options, refer to the
  283. // documentation at:
  284. //
  285. // https://docs.docker.com/engine/reference/commandline/run/#configure-namespaced-kernel-parameters-sysctls-at-runtime
  286. map<string, string> sysctls = 26;
  287. // CapabilityAdd sets the list of capabilities to add to the default capability list
  288. repeated string capability_add = 27;
  289. // CapabilityDrop sets the list of capabilities to drop from the default capability list
  290. repeated string capability_drop = 28;
  291. message Ulimit {
  292. string name = 1;
  293. int64 soft = 2;
  294. int64 hard = 3;
  295. }
  296. // Ulimits defines the list of ulimits to set in the container. This option
  297. // is equivalent to passing --ulimit to docker run.
  298. repeated Ulimit ulimits = 29;
  299. }
  300. // EndpointSpec defines the properties that can be configured to
  301. // access and loadbalance the service.
  302. message EndpointSpec {
  303. // ResolutionMode specifies the mode of resolution to use for
  304. // internal loadbalancing between tasks which are all within
  305. // the cluster. This is sometimes calls east-west data path.
  306. enum ResolutionMode {
  307. option (gogoproto.goproto_enum_prefix) = false;
  308. // VIP resolution mode specifies that the
  309. // service resolves to a logical IP and the requests
  310. // are sent to that logical IP. Packets hitting that
  311. // logical IP are load balanced to a chosen backend.
  312. VIP = 0 [(gogoproto.enumvalue_customname) = "ResolutionModeVirtualIP"];
  313. // DNSRR resolution mode specifies that the
  314. // service directly gets resolved to one of the
  315. // backend IP and the client directly initiates a
  316. // request towards the actual backend. This requires
  317. // that the client does not cache the DNS responses
  318. // when the DNS response TTL is 0.
  319. DNSRR = 1 [(gogoproto.enumvalue_customname) = "ResolutionModeDNSRoundRobin"];
  320. }
  321. ResolutionMode mode = 1;
  322. // List of exposed ports that this service is accessible from
  323. // external to the cluster.
  324. repeated PortConfig ports = 2;
  325. }
  326. // NetworkSpec specifies user defined network parameters.
  327. message NetworkSpec {
  328. Annotations annotations = 1 [(gogoproto.nullable) = false];
  329. // DriverConfig specific configuration consumed by the network driver.
  330. Driver driver_config = 2;
  331. // IPv6Enabled enables support for IPv6 on the network.
  332. bool ipv6_enabled = 3;
  333. // internal restricts external access to the network. This may be
  334. // accomplished by disabling the default gateway or through other means.
  335. bool internal = 4;
  336. IPAMOptions ipam = 5 [(gogoproto.customname) = "IPAM"];
  337. // Attachable allows external(to swarm) entities to manually
  338. // attach to this network. With this flag enabled, external
  339. // entities such as containers running in an worker node in
  340. // the cluster can manually attach to this network and access
  341. // the services attached to this network. If this flag is not
  342. // enabled(default case) no manual attachment to this network
  343. // can happen.
  344. bool attachable = 6;
  345. // Ingress indicates this network will provide the routing-mesh.
  346. // In older versions, the network providing the routing mesh was
  347. // swarm internally created only and it was identified by the name
  348. // "ingress" and the label "com.docker.swarm.internal": "true".
  349. bool ingress = 7;
  350. // ConfigFrom is the source of the configuration for this network.
  351. oneof config_from {
  352. // Network is the name of a network that provides the network
  353. // specific configuration for this network, locally on the node
  354. // where this network is being plumbed.
  355. string network = 8;
  356. }
  357. }
  358. // ClusterSpec specifies global cluster settings.
  359. message ClusterSpec {
  360. Annotations annotations = 1 [(gogoproto.nullable) = false];
  361. // DEPRECATED: AcceptancePolicy defines the certificate issuance policy.
  362. // Acceptance policy is no longer customizable, and secrets have been
  363. // replaced with join tokens.
  364. AcceptancePolicy acceptance_policy = 2 [deprecated=true, (gogoproto.nullable) = false];
  365. // Orchestration defines cluster-level orchestration settings.
  366. OrchestrationConfig orchestration = 3 [(gogoproto.nullable) = false];
  367. // Raft defines the cluster's raft settings.
  368. RaftConfig raft = 4 [(gogoproto.nullable) = false];
  369. // Dispatcher defines cluster-level dispatcher settings.
  370. DispatcherConfig dispatcher = 5 [(gogoproto.nullable) = false];
  371. // CAConfig defines cluster-level certificate authority settings.
  372. CAConfig ca_config = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "CAConfig"];
  373. // TaskDefaults specifies the default values to use for task creation.
  374. TaskDefaults task_defaults = 7 [(gogoproto.nullable) = false];
  375. // EncryptionConfig defines the cluster's encryption settings.
  376. EncryptionConfig encryption_config = 8 [(gogoproto.nullable) = false];
  377. }
  378. // SecretSpec specifies a user-provided secret.
  379. message SecretSpec {
  380. Annotations annotations = 1 [(gogoproto.nullable) = false];
  381. // Data is the secret payload - the maximum size is 500KB (that is, 500*1024 bytes)
  382. bytes data = 2;
  383. // Templating controls whether and how to evaluate the secret payload as
  384. // a template. If it is not set, no templating is used.
  385. //
  386. // The currently recognized values are:
  387. // - golang: Go templating
  388. Driver templating = 3;
  389. // Driver is the the secret driver that is used to store the specified secret
  390. Driver driver = 4;
  391. }
  392. // ConfigSpec specifies user-provided configuration files.
  393. message ConfigSpec {
  394. Annotations annotations = 1 [(gogoproto.nullable) = false];
  395. // Data is the config payload - the maximum size is 500KB (that is, 500*1024 bytes)
  396. // TODO(aaronl): Do we want to revise this to include multiple payloads in a single
  397. // ConfigSpec? Define this to be a tar? etc...
  398. bytes data = 2;
  399. // Templating controls whether and how to evaluate the secret payload as
  400. // a template. If it is not set, no templating is used.
  401. //
  402. // The currently recognized values are:
  403. // - golang: Go templating
  404. Driver templating = 3;
  405. }
  406. message VolumeSpec {
  407. // Annotations includes the name and labels of a volume. The name used in the
  408. // spec's Annotations will be passed to the Plugin as the "Name" in the
  409. // CreateVolume request.
  410. Annotations annotations = 1 [(gogoproto.nullable) = false];
  411. // Group defines the volume group this particular volume belongs to. When
  412. // requesting volumes for a workload, the group name can be used instead of
  413. // the volume's name, which tells swarmkit to pick one from the many volumes
  414. // belonging to that group.
  415. string group = 2;
  416. // Driver represents the CSI Plugin object and its configuration parameters.
  417. // The "options" field of the Driver object is passed in the CSI
  418. // CreateVolumeRequest as the "parameters" field. The Driver must be
  419. // specified; there is no default CSI Plugin.
  420. Driver driver = 3;
  421. // AccessMode is similar to, and used to determine, the volume access mode as
  422. // defined in the CSI spec, as well as the volume type (block vs mount). In
  423. // this way, it is more similar to the VolumeCapability message in the CSI
  424. // spec.
  425. VolumeAccessMode access_mode = 4;
  426. // Secrets represents a set of key/value pairs to pass to the CSI plugin. The
  427. // keys of the secrets can be anything, but the values refer to swarmkit
  428. // Secret objects. See the "Secrets Requirements" section of the CSI Plugin
  429. // Spec for more information.
  430. repeated VolumeSecret secrets = 5;
  431. // AccessibilityRequirements specifies where a volume must be accessible
  432. // from.
  433. //
  434. // This field must be empty if the plugin does not support
  435. // VOLUME_ACCESSIBILITY_CONSTRAINTS capabilities. If it is present but the
  436. // plugin does not support it, volume will not be created.
  437. //
  438. // If AccessibilityRequirements is empty, but the plugin does support
  439. // VOLUME_ACCESSIBILITY_CONSTRAINTS, then Swarmkit will assume the entire
  440. // cluster is a valid target for the volume.
  441. TopologyRequirement AccessibilityRequirements = 6;
  442. // CapacityRange is the capacity this volume should be created with. If nil,
  443. // the plugin will decide the capacity.
  444. CapacityRange capacity_range = 7;
  445. enum VolumeAvailability {
  446. option (gogoproto.goproto_enum_prefix) = false;
  447. // Active allows a volume to be used and scheduled to. This is the
  448. // default state.
  449. ACTIVE = 0 [(gogoproto.enumvalue_customname) = "VolumeAvailabilityActive"];
  450. // Pause prevents volumes from having new workloads scheduled to use
  451. // them, even if they're already published on a Node.
  452. PAUSE = 1 [(gogoproto.enumvalue_customname) = "VolumeAvailabilityPause"];
  453. // Drain causes existing workloads using this volume to be rescheduled,
  454. // causing the volume to be unpublished and removed from nodes.
  455. DRAIN = 2 [(gogoproto.enumvalue_customname) = "VolumeAvailabilityDrain"];
  456. }
  457. // Availability is the Volume's desired availability. Analogous to Node
  458. // Availability, this allows the user to take volumes offline in order to
  459. // update or delete them.
  460. VolumeAvailability availability = 8;
  461. }