github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/api/specs.proto (about)

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