Documentation
¶
Index ¶
- Constants
- func ChangeAPIEndpoint(clusterName, oldEndpoint, newEndpoint, directory string, ...) error
- func FindNewAPIEndpointCandidate(current, desired []*pb.NodePool, excludeNodepoolName *pb.NodePool) (*pb.NodePool, error)
- func GenerateInventoryFile(inventoryTemplate, outputDirectory string, data interface{}) error
- func GenerateLBBaseFiles(outputDirectory string, lbClustersInfo *LBClustersInfo) error
- func HandleAPIEndpointChange(apiServerTypeLBCluster *LBClusterData, k8sCluster *LBClustersInfo, ...) error
- type APIEndpointChangeState
- type Ansible
- type LBClusterData
- type LBClusterRolesInfo
- type LBClustersInfo
- type LBInventoryFileParameters
- type LBPlaybookParameters
- type LBcluster
- type NginxConfigTemplateParameters
- type NodePools
Constants ¶
const (
// File name for the ansible inventory.
InventoryFileName = "inventory.ini"
)
Variables ¶
This section is empty.
Functions ¶
func ChangeAPIEndpoint ¶
func ChangeAPIEndpoint(clusterName, oldEndpoint, newEndpoint, directory string, spawnProcessLimit chan struct{}) error
ChangeAPIEndpoint will change the kubeadm configuration. It will set the Api endpoint of the cluster to the public IP of the newly selected ApiEndpoint node.
func FindNewAPIEndpointCandidate ¶
func FindNewAPIEndpointCandidate(current, desired []*pb.NodePool, excludeNodepoolName *pb.NodePool) (*pb.NodePool, error)
FindNewAPIEndpointCandidate finds control plane nodepools present in both current (excluding the request nodepool) and desired state. Returns the first.
func GenerateInventoryFile ¶
GenerateInventoryFile generates an Ansible inventory file that defines the hosts and groups of hosts that Ansible can manage.
func GenerateLBBaseFiles ¶
func GenerateLBBaseFiles(outputDirectory string, lbClustersInfo *LBClustersInfo) error
GenerateLBBaseFiles generates the files like Ansible inventory file and SSH keys to be used by Ansible. Returns error if not successful, nil otherwise
func HandleAPIEndpointChange ¶
func HandleAPIEndpointChange(apiServerTypeLBCluster *LBClusterData, k8sCluster *LBClustersInfo, outputDirectory string, spawnProcessLimit chan struct{}) error
Types ¶
type APIEndpointChangeState ¶
type APIEndpointChangeState string
const ( // NoChange represents the 1st case - no change is needed as the LB cluster is currently // attached and the desired spec contains no changes. NoChange APIEndpointChangeState = "no-change" // AttachingLoadBalancer represents 2nd case - the K8s cluster previously // didn't have an LB cluster attached and the ports needed to communicate with the API server // were exposed. After attaching an LB cluster to the existing K8s cluster the ports // were closed and are no longer accessible, and thus we need to change the API endpoint. AttachingLoadBalancer APIEndpointChangeState = "attaching-load-balancer" // DetachingLoadBalancer represents 3rd. case - the K8s cluster had an existing // LB cluster attached but the new state removed the LB cluster and thus the API endpoint // needs to be changed back to one of the control nodes of the cluster. DetachingLoadBalancer APIEndpointChangeState = "detaching-load-balancer" // EndpointRenamed represents the 4th. case - the K8s cluster has an existing // LB cluster attached and also keeps it but the endpoint has changed in the desired state. EndpointRenamed APIEndpointChangeState = "endpoint-renamed" // RoleChangedToAPIServer represents the 5th case - the K8s cluster has an existing // LB cluster attached that didn't have a ApiServer role attached but the desired state does. RoleChangedToAPIServer APIEndpointChangeState = "role-changed-to-api-server" // RoleChangedFromAPIServer represents the 6th case - the K8s cluster has an existing // LB cluster attached that had an ApiServer role attached but the desired state doesn't. RoleChangedFromAPIServer APIEndpointChangeState = "role-changed-from-api-server" )
type Ansible ¶
type Ansible struct { Playbook string Inventory string Flags string Directory string // SpawnProcessLimit represents a synchronization channel which limits the number of spawned ansible // processes. This values must be non-nil and be buffered, where the capacity indicates // the limit. SpawnProcessLimit chan struct{} }
func (*Ansible) RunAnsiblePlaybook ¶
RunAnsiblePlaybook executes ansible-playbook with the default forks of defaultAnsibleForks any additional flags like -l <name>, or --extra-vars <vars> include in flags parameter if command unsuccessful, the function will retry it until successful or maxAnsibleRetries reached all commands are executed with ANSIBLE_HOST_KEY_CHECKING set to false
type LBClusterData ¶
type LBClusterData struct { // CurrentLbCluster is the current spec of the LB Cluster. // A value of nil means that the LB cluster doesn't exist currently // and will be created in the future. CurrentLbCluster *pb.LBcluster // DesiredLbCluster is the desired spec of the LB Cluster. // A value of nil means that this LB cluster will be deleted in the future. DesiredLbCluster *pb.LBcluster }
LBClusterData holds details about the current and desired state of an LB cluster.
func FindCurrentAPIServerTypeLBCluster ¶
func FindCurrentAPIServerTypeLBCluster(lbClusters []*LBClusterData) *LBClusterData
FindCurrentAPIServerTypeLBCluster finds the current API server type LB cluster.
func (*LBClusterData) APIEndpointState ¶
func (lb *LBClusterData) APIEndpointState() APIEndpointChangeState
APIEndpointState determines if the API endpoint should be updated with a new address, as otherwise communication with the cluster wouldn't be possible.
type LBClustersInfo ¶
type LBClustersInfo struct { // LbClusters are Load-Balancers that share the targeted k8s cluster. LbClusters []*LBClusterData // TargetK8sNodepool are all nodepools used by the targeted k8s cluster. TargetK8sNodepool []*pb.NodePool // TargetK8sNodepoolKey is the key used for the nodepools. TargetK8sNodepoolKey string // PreviousAPIEndpointLB holds the endpoint of the previous Load-Balancer endpoint // if there was any to be able to handle the endpoint change. PreviousAPIEndpointLB string // ClusterID contains the ClusterName-Hash- prefix of the kubernetes cluster ClusterID string // Indicates whether the manifest has no current state i.e. it's the first time it's being build. FirstRun bool }
LBClustersInfo wraps all Load-balancers and Nodepools used for a single K8s cluster.
type LBPlaybookParameters ¶
type LBPlaybookParameters struct {
Loadbalancer string
}
type NginxConfigTemplateParameters ¶
type NginxConfigTemplateParameters struct {
Roles []LBClusterRolesInfo
}