Documentation ¶
Index ¶
- func GenerateEtcdSystemdService(node Node, etcdNodes []Node) string
- func GenerateMasterConfiguration(masterNode Node, masterNodes []Node, etcdNodes []Node, ...) string
- func GenerateOverlayRouteSystemdService(node Node) string
- func GenerateWireguardConf(node Node, nodes []Node) string
- func PrivateIPPrefix(cidr string) (string, error)
- type Cluster
- type ClusterProvider
- type EtcdManager
- type EventService
- type FilePermission
- type KeepCerts
- type Manager
- func (manager *Manager) AppendNodes(nodes []Node)
- func (manager *Manager) Cluster() Cluster
- func (manager *Manager) DeployLoadBalancer(nodes []Node) error
- func (manager *Manager) InstallEtcdNodes(nodes []Node, keepData bool) error
- func (manager *Manager) InstallMasters(keepCerts KeepCerts) error
- func (manager *Manager) InstallWorkers(nodes []Node) error
- func (manager *Manager) ProvisionNodes(nodes []Node) error
- func (manager *Manager) SetupEncryptedNetwork() error
- func (manager *Manager) SetupHA() error
- type Node
- type NodeCommand
- type NodeCommunicator
- type NodeProvisioner
- type SSHCommunicator
- func (sshComm *SSHCommunicator) CapturePassphrase(sshKeyName string) error
- func (sshComm *SSHCommunicator) CopyFileOverNode(sourceNode Node, targetNode Node, filePath string) error
- func (sshComm *SSHCommunicator) Log(msg ...string)
- func (sshComm *SSHCommunicator) RunCmd(node Node, command string) (output string, err error)
- func (sshComm *SSHCommunicator) TransformFileOverNode(sourceNode Node, targetNode Node, filePath string, ...) error
- func (sshComm *SSHCommunicator) WriteFile(node Node, filePath string, content string, permission FilePermission) error
- type SSHKey
- type WgKeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateEtcdSystemdService ¶
GenerateEtcdSystemdService generate configuration file used to manage etcd service on systemd
func GenerateMasterConfiguration ¶
func GenerateMasterConfiguration(masterNode Node, masterNodes []Node, etcdNodes []Node, kubernetesVersion string) string
GenerateMasterConfiguration generate the kubernetes config for master
func GenerateOverlayRouteSystemdService ¶
GenerateOverlayRouteSystemdService generate configuration file used to manage overlay route service on systemd
func GenerateWireguardConf ¶
GenerateWireguardConf generate wireguard configuration file
func PrivateIPPrefix ¶
PrivateIPPrefix extracts the first 3 digits of an IPv4 address from CIDR block
Types ¶
type Cluster ¶
type Cluster struct { Name string `json:"name"` Nodes []Node `json:"nodes"` HaEnabled bool `json:"ha_enabled"` IsolatedEtcd bool `json:"isolated_etcd"` CloudInitFile string `json:"cloud_init_file"` NodeCIDR string `json:"node_cidr"` KubernetesVersion string `json:"kubernetes_version"` }
Cluster is the structure used to define a cluster
type ClusterProvider ¶
type ClusterProvider interface { SetNodes([]Node) GetAllNodes() []Node GetMasterNodes() []Node GetEtcdNodes() []Node GetWorkerNodes() []Node GetMasterNode() (*Node, error) GetCluster() Cluster GetAdditionalMasterInstallCommands() []NodeCommand GetNodeCidr() string MustWait() bool }
ClusterProvider is the interface used to declare a cluster provider
type EtcdManager ¶
type EtcdManager struct {
// contains filtered or unexported fields
}
EtcdManager is a tool which provides basic backup & restore functionality for HA clusters
func NewEtcdManager ¶
func NewEtcdManager(provider ClusterProvider, nodeCommunicator NodeCommunicator) *EtcdManager
NewEtcdManager returns a new instance of EtcdManager
func (*EtcdManager) CreateSnapshot ¶
func (manager *EtcdManager) CreateSnapshot(name string) error
CreateSnapshot creates a snapshot with a name. If name is empty, a datetime string is generated
func (*EtcdManager) RestoreSnapshot ¶
func (manager *EtcdManager) RestoreSnapshot(name string, skipCopy bool) (bool, error)
RestoreSnapshot restores a snapshot, given its name
type EventService ¶
EventService is the interface used to manage events
type FilePermission ¶
type FilePermission string
FilePermission is the date uesd to define file permission
const ( // OwnerRead indicate that the file can be readed only from owner OwnerRead FilePermission = "C0600" // AllRead indicate that the file can be readed from all user on system AllRead FilePermission = "C0644" // AllExecute indicate that the file can be executed from all user on system AllExecute FilePermission = "C0755" )
type KeepCerts ¶
type KeepCerts int
KeepCerts is an enumeration for existing certificate handling during master install
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the structure used to mange cluster
func NewClusterManager ¶
func NewClusterManager(provider ClusterProvider, nodeCommunicator NodeCommunicator, eventService EventService, name string, haEnabled bool, isolatedEtcd bool, cloudInitFile string) *Manager
NewClusterManager create a new manager for the cluster
func NewClusterManagerFromCluster ¶
func NewClusterManagerFromCluster(cluster Cluster, provider ClusterProvider, nodeCommunicator NodeCommunicator, eventService EventService) *Manager
NewClusterManagerFromCluster create a new manager from an existing cluster
func (*Manager) AppendNodes ¶
AppendNodes can be used to append nodes to the cluster after initialization
func (*Manager) DeployLoadBalancer ¶
DeployLoadBalancer installs a client based load balancer for the master nodes to given nodes
func (*Manager) InstallEtcdNodes ¶
InstallEtcdNodes installs the etcd cluster
func (*Manager) InstallMasters ¶
InstallMasters installs the kubernetes control plane to master nodes
func (*Manager) InstallWorkers ¶
InstallWorkers installs kubernetes workers to given nodes
func (*Manager) ProvisionNodes ¶
ProvisionNodes install packages for the nodes
func (*Manager) SetupEncryptedNetwork ¶
SetupEncryptedNetwork setups an encrypted virtual network using wireguard modifies the state of manager.Nodes
type Node ¶
type Node struct { Name string `json:"name"` Type string `json:"type"` IsMaster bool `json:"is_master"` IsEtcd bool `json:"is_etcd"` IPAddress string `json:"ip_address"` PrivateIPAddress string `json:"private_ip_address"` SSHKeyName string `json:"ssh_key_name"` WireGuardKeyPair WgKeyPair `json:"wire_guard_key_pair"` }
Node is the structure used to define a node
type NodeCommand ¶
NodeCommand is the structure used to define acommand to execute on a node
type NodeCommunicator ¶
type NodeCommunicator interface { RunCmd(node Node, command string) (string, error) WriteFile(node Node, filePath string, content string, permission FilePermission) error CopyFileOverNode(source Node, target Node, filePath string) error TransformFileOverNode(source Node, target Node, filePath string, transform func(string) string) error }
NodeCommunicator is the interface used to define a node comunication protocol
func NewSSHCommunicator ¶
func NewSSHCommunicator(sshKeys []SSHKey, debug bool) NodeCommunicator
NewSSHCommunicator creates an instance of SSHCommunicator
type NodeProvisioner ¶
type NodeProvisioner struct {
// contains filtered or unexported fields
}
NodeProvisioner provisions all basic packages to install docker, kubernetes and wireguard
func NewNodeProvisioner ¶
func NewNodeProvisioner(node Node, manager *Manager) *NodeProvisioner
NewNodeProvisioner creates a NodeProvisioner instance
func (*NodeProvisioner) Provision ¶
func (provisioner *NodeProvisioner) Provision(node Node, communicator NodeCommunicator, eventService EventService) error
Provision performs all steps to provision a node
type SSHCommunicator ¶
type SSHCommunicator struct {
// contains filtered or unexported fields
}
SSHCommunicator implements NodeCommunicator as a SSH client
func (*SSHCommunicator) CapturePassphrase ¶
func (sshComm *SSHCommunicator) CapturePassphrase(sshKeyName string) error
CapturePassphrase asks the user to enter a private keys passphrase
func (*SSHCommunicator) CopyFileOverNode ¶
func (sshComm *SSHCommunicator) CopyFileOverNode(sourceNode Node, targetNode Node, filePath string) error
CopyFileOverNode copies a file from a node to another. Does not work with directories.
func (*SSHCommunicator) Log ¶
func (sshComm *SSHCommunicator) Log(msg ...string)
Log is an helper method that allow to print logs
func (*SSHCommunicator) RunCmd ¶
func (sshComm *SSHCommunicator) RunCmd(node Node, command string) (output string, err error)
RunCmd runs a bash command on the given node
func (*SSHCommunicator) TransformFileOverNode ¶
func (sshComm *SSHCommunicator) TransformFileOverNode(sourceNode Node, targetNode Node, filePath string, manipulator func(string) string) error
TransformFileOverNode works like CopyFileOverNode, with the addition of changing the file contents using a func(string) string function
func (*SSHCommunicator) WriteFile ¶
func (sshComm *SSHCommunicator) WriteFile(node Node, filePath string, content string, permission FilePermission) error
WriteFile places a file at a given part from string. Permissions are 0644, or 0755 if executable true
type SSHKey ¶
type SSHKey struct { Name string `json:"name"` PrivateKeyPath string `json:"private_key_path"` PublicKeyPath string `json:"public_key_path"` }
SSHKey represents a keypair with the paths to the keys
type WgKeyPair ¶
WgKeyPair containse key pairs
func GenerateKeyPair ¶
GenerateKeyPair create a key-pair used to instantiate a wireguard connection Code is redacted from https://github.com/WireGuard/wireguard-go/blob/1c025570139f614f2083b935e2c58d5dbf199c2f/noise-helpers.go