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