Documentation ¶
Index ¶
- Constants
- func AddMasters(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus, ...) error
- func AddNodeToEtcd(clusterCfg *BootstrapConfig, currMasters *[]HostConfig, hostIp string) error
- func CertsExist(clusterName string) bool
- func ConfigClusterDNS(cfgPath string) error
- func CreateCluster(cfgPath string) error
- func CreateSSHClient(host string, user string, privateKey []byte, port int) (ssh.Client, error)
- func CreateSSHClientRaw(host string, user string, privateKey []byte, port int) (ssh.Client, error)
- func DeleteCluster(cfgPath string) error
- func DeleteWorkers(clusterCfg *BootstrapConfig, oldNodes []HostConfig) error
- func DeployCluster(clusterCfg *BootstrapConfig) error
- func DeployWorkers(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus, ...) error
- func EncloseIpV6(ip string) string
- func GenCALocal(clusterName string) (string, error)
- func GenKubeconfig(cfg *BootstrapConfig) error
- func GenNodeletConfigLocal(host *NodeletConfig, templateName string) (string, error)
- func GetCurrentMasters(clusterCfg *BootstrapConfig) ([]string, error)
- func GetCurrentWorkers(clusterCfg *BootstrapConfig) ([]string, error)
- func GetLocalClient() ssh.Client
- func InitEtcdClient(clusterCfg *BootstrapConfig, activeMasters *[]HostConfig) (*clientv3.Client, error)
- func IsIpV6Addr(host string) bool
- func IsLocal(nodeName string) (bool, error)
- func RegenCA(cfg *BootstrapConfig) error
- func RegenClusterCerts(cfgPath string) error
- func RemoveMasters(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus, ...) error
- func RemoveNodeFromEtcd(clusterCfg *BootstrapConfig, currMasters *[]HostConfig, hostIp string) error
- func RenewCAIfExpiring(cfg *BootstrapConfig) error
- func ScaleCluster(cfgPath string) error
- func SetClusterNodeStatus(status *ClusterStatus, nodeName, health string, err error)
- func SyncAndRetry(clusterCfg *BootstrapConfig, nodeletStatus *ClusterStatus, ...)
- func SyncNodes(clusterCfg *BootstrapConfig, nodes *[]HostConfig) error
- func UpgradeCluster(cfgPath string) error
- func UpgradeWorkers(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus) error
- func UploadFileWrapper(srcFilePath, fileName, dstDir string, client ssh.Client) error
- func UploadHostsFile(clusterCfg *BootstrapConfig) error
- func WriteHostsFileForEntries(clusterName string, entries []string) (string, error)
- type BootstrapConfig
- type CalicoConfig
- type ClusterClient
- type ClusterStatus
- type ContainerRuntimeConfig
- type CoreDNSConfig
- type HostConfig
- type KubeConfigData
- type LocalClient
- type NodeStatus
- type NodeletConfig
- type NodeletDeployer
- func (nd *NodeletDeployer) CopyNodeletConfig() error
- func (nd *NodeletDeployer) CreatePf9User() error
- func (nd *NodeletDeployer) DeleteCniDir() error
- func (nd *NodeletDeployer) DeleteNodelet() error
- func (nd *NodeletDeployer) DeleteOldCerts() error
- func (nd *NodeletDeployer) DeployNodelet() error
- func (nd *NodeletDeployer) DetermineNodeletPkgName(nodeletPkgsDir string) (string, error)
- func (nd *NodeletDeployer) InstallNodelet() error
- func (nd *NodeletDeployer) NodeletStackRestart() error
- func (nd *NodeletDeployer) ReconfigureNodelet() error
- func (nd *NodeletDeployer) RefreshNodeletStatus() (string, error)
- func (nd *NodeletDeployer) RestartNodelet() error
- func (nd *NodeletDeployer) SetOsType()
- func (nd *NodeletDeployer) SetPf9Ownerships() error
- func (nd *NodeletDeployer) SpawnMaster(numMaster int) (string, error)
- func (nd *NodeletDeployer) SpawnWorker(wg *sync.WaitGroup)
- func (nd *NodeletDeployer) StartNodelet() error
- func (nd *NodeletDeployer) UninstallNodelet(nodeletPkgName string) error
- func (nd *NodeletDeployer) UpgradeMaster() error
- func (nd *NodeletDeployer) UpgradeWorker(wg *sync.WaitGroup)
- func (nd *NodeletDeployer) UploadCerts() error
- func (nd *NodeletDeployer) UploadCertsAndRestartStack(wg *sync.WaitGroup) error
- func (nd *NodeletDeployer) UploadCoreDNSHostsFile() error
- func (nd *NodeletDeployer) UploadUserImages() error
Constants ¶
const ( DefaultClusterName = "airctl-mgmt" ClusterStateDir = "/etc/nodelet/" NodeletConfigDir = "/etc/pf9/nodelet" NodeletConfigFile = "config_sunpike.yaml" NodeletUser = "pf9" NodeletTarSrc = "/opt/pf9/airctl/nodelet/nodelet.tar.gz" NodeletTarDst = "/tmp/nodelet.tar.gz" NodeletPkgsTmpDir = "/tmp/nodelet-pkgs/" OsTypeCentos = "centos" OsTypeUbuntu = "ubuntu" NodeConverged = "converging" NodeHealthy = "ok" CACertExpiryYears = 3 CAExpiryLimitDays = 90 RootCACRT = "rootCA.crt" RootCAKey = "rootCA.key" AdminKubeconfig = "admin.kubeconfig" RemoteCertsDir = "/etc/pf9/kube.d/" KubeStatusFile = "/var/opt/pf9/kube_status" SyncRetrySeconds = 30 ClusterTimeout = 30 WorkerLabel = "node-role.kubernetes.io/worker" MasterLabel = "node-role.kubernetes.io/master" UserImagesDir = "/var/opt/pf9/images" CAPath = "/etc/pki/ca-trust/source/anchors/nodelet-ca.pem" DefaultCalicoV4Cidr = "10.20.0.0/22" DefaultCalicoV6Cidr = "fd00:101::/116" DefaultV4ServicesCidr = "10.21.0.0/22" DefaultV6ServicesCidr = "fd00:102::/116" )
Variables ¶
This section is empty.
Functions ¶
func AddMasters ¶
func AddMasters(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus, currMasters, newMasters *[]HostConfig) error
func AddNodeToEtcd ¶
func AddNodeToEtcd(clusterCfg *BootstrapConfig, currMasters *[]HostConfig, hostIp string) error
func CertsExist ¶
func ConfigClusterDNS ¶
func CreateCluster ¶
func CreateSSHClient ¶
* CreateSSHClient: connects to given host on port with given user and key. * The function retries the operation total 5 times on failure attempt after waiting for 60 seconds.
func CreateSSHClientRaw ¶
* CreateSSHClientRaw: connects to given host on port with given user and key
func DeleteCluster ¶
func DeleteWorkers ¶
func DeleteWorkers(clusterCfg *BootstrapConfig, oldNodes []HostConfig) error
func DeployCluster ¶
func DeployCluster(clusterCfg *BootstrapConfig) error
func DeployWorkers ¶
func DeployWorkers(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus, workers *[]HostConfig) error
func EncloseIpV6 ¶
func GenCALocal ¶
func GenKubeconfig ¶
func GenKubeconfig(cfg *BootstrapConfig) error
func GenNodeletConfigLocal ¶
func GenNodeletConfigLocal(host *NodeletConfig, templateName string) (string, error)
func GetCurrentMasters ¶
func GetCurrentMasters(clusterCfg *BootstrapConfig) ([]string, error)
func GetCurrentWorkers ¶
func GetCurrentWorkers(clusterCfg *BootstrapConfig) ([]string, error)
func GetLocalClient ¶
func InitEtcdClient ¶
func InitEtcdClient(clusterCfg *BootstrapConfig, activeMasters *[]HostConfig) (*clientv3.Client, error)
func IsIpV6Addr ¶
func RegenCA ¶
func RegenCA(cfg *BootstrapConfig) error
func RegenClusterCerts ¶
func RemoveMasters ¶
func RemoveMasters(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus, currMasters, oldMasters *[]HostConfig) error
func RemoveNodeFromEtcd ¶
func RemoveNodeFromEtcd(clusterCfg *BootstrapConfig, currMasters *[]HostConfig, hostIp string) error
func RenewCAIfExpiring ¶
func RenewCAIfExpiring(cfg *BootstrapConfig) error
func ScaleCluster ¶
func SetClusterNodeStatus ¶
func SetClusterNodeStatus(status *ClusterStatus, nodeName, health string, err error)
func SyncAndRetry ¶
func SyncAndRetry(clusterCfg *BootstrapConfig, nodeletStatus *ClusterStatus, nodesToSync *[]HostConfig, done chan bool)
func SyncNodes ¶
func SyncNodes(clusterCfg *BootstrapConfig, nodes *[]HostConfig) error
func UpgradeCluster ¶
func UpgradeWorkers ¶
func UpgradeWorkers(clusterCfg *BootstrapConfig, clusterStatus *ClusterStatus) error
func UploadFileWrapper ¶
Copying files follows a predictable pattern
- Make the remote directory, if it doesn't exist
- Set permissions to pf9:pf9group
- Upload to /tmp/ because ssh user may be different, and SFTP client used by pf9ctl.UploadFile only allows access to home directory and /tmp
- Finally, move to target directory
func UploadHostsFile ¶
func UploadHostsFile(clusterCfg *BootstrapConfig) error
Types ¶
type BootstrapConfig ¶
type BootstrapConfig struct { SSHUser string `json:"sshUser,omitempty"` SSHPrivateKeyFile string `json:"sshPrivateKeyFile,omitempty"` CertsDir string `json:"certsDir,omitempty"` KubeConfig string `json:"kubeconfig,omitempty"` Pf9KubePkg string `json:"nodeletPkg,omitempty"` ClusterId string `json:"clusterName,omitempty"` AllowWorkloadsOnMaster bool `json:"allowWorkloadsOnMaster,omitempty"` K8sApiPort string `json:"k8sApiPort,omitempty"` MasterIp string `json:"masterIp,omitempty"` MasterVipEnabled bool `json:"masterVipEnabled,omitempty"` MasterVipInterface string `json:"masterVipInterface,omitempty"` MasterVipVrouterId int `json:"masterVipVrouterId,omitempty"` MTU string `json:"mtu,omitempty"` Privileged string `json:"privileged,omitempty"` ContainerRuntime ContainerRuntimeConfig `json:"containerRuntime,omitempty"` UserImages []string `json:"userImages,omitempty"` DNS CoreDNSConfig `json:"dns,omitempty"` UseHostname bool `json:"useHostname,omitempty"` IPv6Enabled bool `json:"ipv6,omitempty"` Calico CalicoConfig `json:"calico,omitempty"` ServicesCidr string `json:"servicesCidr,omitempty"` MasterNodes []HostConfig `json:"masterNodes"` WorkerNodes []HostConfig `json:"workerNodes"` }
func InitBootstrapConfig ¶
func InitBootstrapConfig() *BootstrapConfig
func ParseBootstrapConfig ¶
func ParseBootstrapConfig(cfgPath string) (*BootstrapConfig, error)
type CalicoConfig ¶
type CalicoConfig struct { V4Interface string `json:"v4Interface,omitempty"` V6Interface string `json:"v6Interface,omitempty"` V4ContainersCidr string `json:"v4ContainersCidr,omitempty"` V6ContainersCidr string `json:"v6ContainersCidr,omitempty"` V4BlockSize int `json:"v4BlockSize,omitempty"` V6BlockSize int `json:"v6BlockSize,omitempty"` V4NATOutgoing bool `json:"v4NATOutgoing,omitempty"` V6NATOutgoing bool `json:"v6NATOutgoing,omitempty"` V4IpIpMode string `json:"v4IpIpMode,omitempty"` }
type ClusterClient ¶
type ClusterClient struct {
// contains filtered or unexported fields
}
func GetClient ¶
func GetClient(clusterCfg *BootstrapConfig) (*ClusterClient, error)
func (*ClusterClient) GetMatchingNodes ¶
func (c *ClusterClient) GetMatchingNodes(labels ...string) ([]string, error)
type ClusterStatus ¶
type ClusterStatus struct {
// contains filtered or unexported fields
}
func GetClusterNodeletStatus ¶
func GetClusterNodeletStatus(clusterCfg *BootstrapConfig, nodes *[]HostConfig) (*ClusterStatus, error)
type ContainerRuntimeConfig ¶
type CoreDNSConfig ¶
type HostConfig ¶
type KubeConfigData ¶
type LocalClient ¶
type LocalClient struct { }
Client interface provides ways to run command and upload files to remote hosts
func (*LocalClient) DownloadFile ¶
func (client *LocalClient) DownloadFile(remoteFile, localPath string, mode os.FileMode, cb func(read int64, total int64)) error
Downloadfile downloads the remoteFile to localFile and changes the mode to the filemode
func (*LocalClient) RunCommand ¶
func (client *LocalClient) RunCommand(command string) ([]byte, []byte, error)
RunCommand executes the remote command returning the stdout, stderr and any error associated with it
func (*LocalClient) UploadFile ¶
func (client *LocalClient) UploadFile(srcFilePath, remoteDstFilePath string, mode os.FileMode, cb func(read int64, total int64)) error
Uploadfile uploads the srcFile to remoteDestFilePath and changes the mode to the filemode
type NodeStatus ¶
type NodeStatus struct {
// contains filtered or unexported fields
}
type NodeletConfig ¶
type NodeletConfig struct { AllowWorkloadsOnMaster bool CalicoV4Interface string CalicoV6Interface string ClusterId string ContainerRuntime ContainerRuntimeConfig EtcdClusterState string HostId string HostIp string K8sApiPort string MasterList *map[string]string MasterIp string MasterVipEnabled bool MasterVipInterface string MasterVipVrouterId int Mtu string Privileged string NodeletRole string UserImages []string CoreDNSHostsFile string IPv6Enabled bool UseHostname bool CalicoIP4 string CalicoIP6 string CalicoV4BlockSize int CalicoV6BlockSize int CalicoV6ContainersCidr string CalicoV4ContainersCidr string CalicoV4NATOutgoing bool CalicoV6NATOutgoing bool CalicoV4IpIpMode string ContainersCidr string ServicesCidr string }
type NodeletDeployer ¶
type NodeletDeployer struct { OsType string // contains filtered or unexported fields }
func GetNodeletDeployer ¶
func GetNodeletDeployer(cfg *BootstrapConfig, clusterStatus *ClusterStatus, nodeletCfg *NodeletConfig, nodeletSrcFile string) (*NodeletDeployer, error)
func NewNodeletDeployer ¶
func NewNodeletDeployer(cfg *BootstrapConfig, sshClient ssh.Client, srcFile string, nodeletCfg *NodeletConfig, clusterStatus *ClusterStatus) *NodeletDeployer
func (*NodeletDeployer) CopyNodeletConfig ¶
func (nd *NodeletDeployer) CopyNodeletConfig() error
func (*NodeletDeployer) CreatePf9User ¶
func (nd *NodeletDeployer) CreatePf9User() error
func (*NodeletDeployer) DeleteCniDir ¶
func (nd *NodeletDeployer) DeleteCniDir() error
func (*NodeletDeployer) DeleteNodelet ¶
func (nd *NodeletDeployer) DeleteNodelet() error
func (*NodeletDeployer) DeleteOldCerts ¶
func (nd *NodeletDeployer) DeleteOldCerts() error
func (*NodeletDeployer) DeployNodelet ¶
func (nd *NodeletDeployer) DeployNodelet() error
func (*NodeletDeployer) DetermineNodeletPkgName ¶
func (nd *NodeletDeployer) DetermineNodeletPkgName(nodeletPkgsDir string) (string, error)
func (*NodeletDeployer) InstallNodelet ¶
func (nd *NodeletDeployer) InstallNodelet() error
func (*NodeletDeployer) NodeletStackRestart ¶
func (nd *NodeletDeployer) NodeletStackRestart() error
func (*NodeletDeployer) ReconfigureNodelet ¶
func (nd *NodeletDeployer) ReconfigureNodelet() error
func (*NodeletDeployer) RefreshNodeletStatus ¶
func (nd *NodeletDeployer) RefreshNodeletStatus() (string, error)
func (*NodeletDeployer) RestartNodelet ¶
func (nd *NodeletDeployer) RestartNodelet() error
func (*NodeletDeployer) SetOsType ¶
func (nd *NodeletDeployer) SetOsType()
func (*NodeletDeployer) SetPf9Ownerships ¶
func (nd *NodeletDeployer) SetPf9Ownerships() error
This is a temporary workaround, normally done by hostagent
TODO: Add to the nodelet after-install.sh script
func (*NodeletDeployer) SpawnMaster ¶
func (nd *NodeletDeployer) SpawnMaster(numMaster int) (string, error)
func (*NodeletDeployer) SpawnWorker ¶
func (nd *NodeletDeployer) SpawnWorker(wg *sync.WaitGroup)
func (*NodeletDeployer) StartNodelet ¶
func (nd *NodeletDeployer) StartNodelet() error
func (*NodeletDeployer) UninstallNodelet ¶
func (nd *NodeletDeployer) UninstallNodelet(nodeletPkgName string) error
func (*NodeletDeployer) UpgradeMaster ¶
func (nd *NodeletDeployer) UpgradeMaster() error
func (*NodeletDeployer) UpgradeWorker ¶
func (nd *NodeletDeployer) UpgradeWorker(wg *sync.WaitGroup)
func (*NodeletDeployer) UploadCerts ¶
func (nd *NodeletDeployer) UploadCerts() error
func (*NodeletDeployer) UploadCertsAndRestartStack ¶
func (nd *NodeletDeployer) UploadCertsAndRestartStack(wg *sync.WaitGroup) error
func (*NodeletDeployer) UploadCoreDNSHostsFile ¶
func (nd *NodeletDeployer) UploadCoreDNSHostsFile() error
func (*NodeletDeployer) UploadUserImages ¶
func (nd *NodeletDeployer) UploadUserImages() error