github.com/rumpl/bof@v23.0.0-rc.2+incompatible/api/types/swarm/swarm.go (about)

     1  package swarm // import "github.com/docker/docker/api/types/swarm"
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // ClusterInfo represents info about the cluster for outputting in "info"
     8  // it contains the same information as "Swarm", but without the JoinTokens
     9  type ClusterInfo struct {
    10  	ID string
    11  	Meta
    12  	Spec                   Spec
    13  	TLSInfo                TLSInfo
    14  	RootRotationInProgress bool
    15  	DefaultAddrPool        []string
    16  	SubnetSize             uint32
    17  	DataPathPort           uint32
    18  }
    19  
    20  // Swarm represents a swarm.
    21  type Swarm struct {
    22  	ClusterInfo
    23  	JoinTokens JoinTokens
    24  }
    25  
    26  // JoinTokens contains the tokens workers and managers need to join the swarm.
    27  type JoinTokens struct {
    28  	// Worker is the join token workers may use to join the swarm.
    29  	Worker string
    30  	// Manager is the join token managers may use to join the swarm.
    31  	Manager string
    32  }
    33  
    34  // Spec represents the spec of a swarm.
    35  type Spec struct {
    36  	Annotations
    37  
    38  	Orchestration    OrchestrationConfig `json:",omitempty"`
    39  	Raft             RaftConfig          `json:",omitempty"`
    40  	Dispatcher       DispatcherConfig    `json:",omitempty"`
    41  	CAConfig         CAConfig            `json:",omitempty"`
    42  	TaskDefaults     TaskDefaults        `json:",omitempty"`
    43  	EncryptionConfig EncryptionConfig    `json:",omitempty"`
    44  }
    45  
    46  // OrchestrationConfig represents orchestration configuration.
    47  type OrchestrationConfig struct {
    48  	// TaskHistoryRetentionLimit is the number of historic tasks to keep per instance or
    49  	// node. If negative, never remove completed or failed tasks.
    50  	TaskHistoryRetentionLimit *int64 `json:",omitempty"`
    51  }
    52  
    53  // TaskDefaults parameterizes cluster-level task creation with default values.
    54  type TaskDefaults struct {
    55  	// LogDriver selects the log driver to use for tasks created in the
    56  	// orchestrator if unspecified by a service.
    57  	//
    58  	// Updating this value will only have an affect on new tasks. Old tasks
    59  	// will continue use their previously configured log driver until
    60  	// recreated.
    61  	LogDriver *Driver `json:",omitempty"`
    62  }
    63  
    64  // EncryptionConfig controls at-rest encryption of data and keys.
    65  type EncryptionConfig struct {
    66  	// AutoLockManagers specifies whether or not managers TLS keys and raft data
    67  	// should be encrypted at rest in such a way that they must be unlocked
    68  	// before the manager node starts up again.
    69  	AutoLockManagers bool
    70  }
    71  
    72  // RaftConfig represents raft configuration.
    73  type RaftConfig struct {
    74  	// SnapshotInterval is the number of log entries between snapshots.
    75  	SnapshotInterval uint64 `json:",omitempty"`
    76  
    77  	// KeepOldSnapshots is the number of snapshots to keep beyond the
    78  	// current snapshot.
    79  	KeepOldSnapshots *uint64 `json:",omitempty"`
    80  
    81  	// LogEntriesForSlowFollowers is the number of log entries to keep
    82  	// around to sync up slow followers after a snapshot is created.
    83  	LogEntriesForSlowFollowers uint64 `json:",omitempty"`
    84  
    85  	// ElectionTick is the number of ticks that a follower will wait for a message
    86  	// from the leader before becoming a candidate and starting an election.
    87  	// ElectionTick must be greater than HeartbeatTick.
    88  	//
    89  	// A tick currently defaults to one second, so these translate directly to
    90  	// seconds currently, but this is NOT guaranteed.
    91  	ElectionTick int
    92  
    93  	// HeartbeatTick is the number of ticks between heartbeats. Every
    94  	// HeartbeatTick ticks, the leader will send a heartbeat to the
    95  	// followers.
    96  	//
    97  	// A tick currently defaults to one second, so these translate directly to
    98  	// seconds currently, but this is NOT guaranteed.
    99  	HeartbeatTick int
   100  }
   101  
   102  // DispatcherConfig represents dispatcher configuration.
   103  type DispatcherConfig struct {
   104  	// HeartbeatPeriod defines how often agent should send heartbeats to
   105  	// dispatcher.
   106  	HeartbeatPeriod time.Duration `json:",omitempty"`
   107  }
   108  
   109  // CAConfig represents CA configuration.
   110  type CAConfig struct {
   111  	// NodeCertExpiry is the duration certificates should be issued for
   112  	NodeCertExpiry time.Duration `json:",omitempty"`
   113  
   114  	// ExternalCAs is a list of CAs to which a manager node will make
   115  	// certificate signing requests for node certificates.
   116  	ExternalCAs []*ExternalCA `json:",omitempty"`
   117  
   118  	// SigningCACert and SigningCAKey specify the desired signing root CA and
   119  	// root CA key for the swarm.  When inspecting the cluster, the key will
   120  	// be redacted.
   121  	SigningCACert string `json:",omitempty"`
   122  	SigningCAKey  string `json:",omitempty"`
   123  
   124  	// If this value changes, and there is no specified signing cert and key,
   125  	// then the swarm is forced to generate a new root certificate ane key.
   126  	ForceRotate uint64 `json:",omitempty"`
   127  }
   128  
   129  // ExternalCAProtocol represents type of external CA.
   130  type ExternalCAProtocol string
   131  
   132  // ExternalCAProtocolCFSSL CFSSL
   133  const ExternalCAProtocolCFSSL ExternalCAProtocol = "cfssl"
   134  
   135  // ExternalCA defines external CA to be used by the cluster.
   136  type ExternalCA struct {
   137  	// Protocol is the protocol used by this external CA.
   138  	Protocol ExternalCAProtocol
   139  
   140  	// URL is the URL where the external CA can be reached.
   141  	URL string
   142  
   143  	// Options is a set of additional key/value pairs whose interpretation
   144  	// depends on the specified CA type.
   145  	Options map[string]string `json:",omitempty"`
   146  
   147  	// CACert specifies which root CA is used by this external CA.  This certificate must
   148  	// be in PEM format.
   149  	CACert string
   150  }
   151  
   152  // InitRequest is the request used to init a swarm.
   153  type InitRequest struct {
   154  	ListenAddr       string
   155  	AdvertiseAddr    string
   156  	DataPathAddr     string
   157  	DataPathPort     uint32
   158  	ForceNewCluster  bool
   159  	Spec             Spec
   160  	AutoLockManagers bool
   161  	Availability     NodeAvailability
   162  	DefaultAddrPool  []string
   163  	SubnetSize       uint32
   164  }
   165  
   166  // JoinRequest is the request used to join a swarm.
   167  type JoinRequest struct {
   168  	ListenAddr    string
   169  	AdvertiseAddr string
   170  	DataPathAddr  string
   171  	RemoteAddrs   []string
   172  	JoinToken     string // accept by secret
   173  	Availability  NodeAvailability
   174  }
   175  
   176  // UnlockRequest is the request used to unlock a swarm.
   177  type UnlockRequest struct {
   178  	// UnlockKey is the unlock key in ASCII-armored format.
   179  	UnlockKey string
   180  }
   181  
   182  // LocalNodeState represents the state of the local node.
   183  type LocalNodeState string
   184  
   185  const (
   186  	// LocalNodeStateInactive INACTIVE
   187  	LocalNodeStateInactive LocalNodeState = "inactive"
   188  	// LocalNodeStatePending PENDING
   189  	LocalNodeStatePending LocalNodeState = "pending"
   190  	// LocalNodeStateActive ACTIVE
   191  	LocalNodeStateActive LocalNodeState = "active"
   192  	// LocalNodeStateError ERROR
   193  	LocalNodeStateError LocalNodeState = "error"
   194  	// LocalNodeStateLocked LOCKED
   195  	LocalNodeStateLocked LocalNodeState = "locked"
   196  )
   197  
   198  // Info represents generic information about swarm.
   199  type Info struct {
   200  	NodeID   string
   201  	NodeAddr string
   202  
   203  	LocalNodeState   LocalNodeState
   204  	ControlAvailable bool
   205  	Error            string
   206  
   207  	RemoteManagers []Peer
   208  	Nodes          int `json:",omitempty"`
   209  	Managers       int `json:",omitempty"`
   210  
   211  	Cluster *ClusterInfo `json:",omitempty"`
   212  
   213  	Warnings []string `json:",omitempty"`
   214  }
   215  
   216  // Status provides information about the current swarm status and role,
   217  // obtained from the "Swarm" header in the API response.
   218  type Status struct {
   219  	// NodeState represents the state of the node.
   220  	NodeState LocalNodeState
   221  
   222  	// ControlAvailable indicates if the node is a swarm manager.
   223  	ControlAvailable bool
   224  }
   225  
   226  // Peer represents a peer.
   227  type Peer struct {
   228  	NodeID string
   229  	Addr   string
   230  }
   231  
   232  // UpdateFlags contains flags for SwarmUpdate.
   233  type UpdateFlags struct {
   234  	RotateWorkerToken      bool
   235  	RotateManagerToken     bool
   236  	RotateManagerUnlockKey bool
   237  }