Documentation ¶
Index ¶
- Constants
- func HasString(a []string, x string) bool
- func ParseLabels(q string) (url.Values, error)
- type ClusterInfo
- type Clusterfile
- type Config
- type Manager
- func (m *Manager) CreateSwarm(vms VMNodes, force bool) error
- func (m *Manager) DrainNodes(nodes []string) error
- func (m *Manager) GetInfo() (NodeInfo, error)
- func (m *Manager) GetManagers() ([]NodeInfo, error)
- func (m *Manager) GetNodes() ([]NodeStatus, error)
- func (m *Manager) JoinToken(tokenType string) (string, error)
- func (m *Manager) LabelNode(node VMNode) error
- func (m *Manager) Runner() runcmd.Runner
- func (m *Manager) SwitchNode(nodeAddr string) error
- func (m *Manager) SwitchNodeVia(nodeAddr string) error
- func (m *Manager) Switcher() Switcher
- func (m *Manager) UpdateSwarm(vms VMNodes) error
- type NodeInfo
- type NodeStatus
- type Nodes
- type Option
- type RemoteManager
- type SwarmInfo
- type Switcher
- type TaskStatus
- type Tasks
- type VMNode
- type VMNodes
Constants ¶
const ( // RoleTag is the tag (Custom Attribute in vSphere) // for tagging VM(s) with either "manager" or "worker" // This is used to assign Docker Swarm roles to VM(s). RoleTag = "role" // ManagerRole denotates a Docker Swarm role of "manager" ManagerRole = "manager" // WorkerRole denotates a Docker Swarm role of "worker" WorkerRole = "worker" // LabelsTag is the tag (Custom Attribute in vSphere) // for freeform labels applied to VM(s) in the form // `key1=value1&key2=value2&key3&key4` // (This uses the URL Query String format). LabelsTag = "labels" )
const (
DefaultTimeout = time.Minute * 5
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusterInfo ¶
type Clusterfile ¶
type Clusterfile struct { Region string `json:"region"` Environment string `json:"environment"` Cluster string `json:"cluster"` Domain string `json:"domain"` Nodes VMNodes `json:"nodes"` }
Clusterfile represents a set of VMNode(s) as a collection of VM(s) along with the region, enviornment, cluster and domain those nodes belong to.
func ReadClusterfile ¶
func ReadClusterfile(r io.Reader) (Clusterfile, error)
ReadClusterfile reads a `Clusterfile` or `Clusterfile.json` from an `io.Reader` such as an open file or stadnard input and parses it into a `ClusterInfo` struct.
func (*Clusterfile) Validate ¶
func (cf *Clusterfile) Validate() error
type Config ¶
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages all operations of a Docker Swarm cluster with flexible Switcher implementations that permit talking to Docker Nodes over different types of transport (e.g: local or remote).
func NewManager ¶
NewManager constructs a new Manager type with the provider Switcher
func (*Manager) CreateSwarm ¶
CreateSwarm creates a new Docker Swarm cluster given a set of nodes
func (*Manager) DrainNodes ¶
DrainNodes drains one or more nodes from an existing Docker Swarm cluster and blocks until there are no more tasks running on thoese nodes.
func (*Manager) GetManagers ¶
GetManagers returns a list of manager nodes and their information
func (*Manager) GetNodes ¶
func (m *Manager) GetNodes() ([]NodeStatus, error)
GetNodes returns all nodes in the cluster
func (*Manager) JoinToken ¶
JoinToken retrieves the current join token for the given type "manager" or "worker" from any of the managers in the cluster
func (*Manager) Runner ¶
func (m *Manager) Runner() runcmd.Runner
Runner returns the current Runner for the current Switcher being used
func (*Manager) SwitchNode ¶
SwitchNode switches to a new node given by nodeAddr to perform operations on
func (*Manager) SwitchNodeVia ¶
SwitchNodeVia switches to a new node given by nodeAddr by jumping through the current node as a "bastion" host to perform operations on the node.
func (*Manager) UpdateSwarm ¶
UpdateSwarm updates an existing Docker Swarm cluster by adding any missing manager or worker nodes that aren't already part of the cluster
type NodeInfo ¶
type NodeStatus ¶
type Nodes ¶
type Nodes []NodeStatus
type Option ¶
func WithTimeout ¶
type RemoteManager ¶
type SwarmInfo ¶
type SwarmInfo struct { NodeID string NodeAddr string LocalNodeState string ControlAvailable bool Nodes int Managers int RemoteManagers []RemoteManager Cluster ClusterInfo }
type Switcher ¶
type Switcher interface { fmt.Stringer Switch(ctx context.Context, nodeAddr string) error SwitchVia(ctx context.Context, nodeAddr string) error Runner() runcmd.Runner }
Switcher is the interface that describes how to switch between Docker Nodes Implementations must implement the `Swithc()` method that should return an appropriate `runcmd.Runner` interface type for operating on Docker Nodes.
func NewLocalSwitcher ¶
NewLocalSwitcher constructs a new Switcher that talks directly to a local Docker UNIX Socket on a single-node
func NewNullSwitcher ¶
type TaskStatus ¶
type TaskStatus struct { ID string Name string Image string Error string Node string Ports string CurrentState string DesiredState string }
func (TaskStatus) Shutdown ¶
func (t TaskStatus) Shutdown() bool
type VMNode ¶
type VMNode struct { Hostname string `json:"hostname"` PublicAddress string `json:"public_address"` PrivateAddress string `json:"private_address"` Tags map[string]string `json:"tags"` }
VMNode represents a single VM Node and at a bare minimum contains the node's hostname, private and public ip addresses as well as a list of tags used to label the nodes for different purposes such as Manager ndoes.
type VMNodes ¶
type VMNodes []VMNode