Documentation ¶
Index ¶
- Constants
- Variables
- func ControlPlaneLabelsForCluster(clusterName string) map[string]string
- func PickFewest(failureDomains clusterv1.FailureDomains, machines FilterableMachineCollection) *string
- func PickMost(c *ControlPlane, machines FilterableMachineCollection) *string
- type ClusterStatus
- type ControlPlane
- func (c *ControlPlane) AsOwnerReference() *metav1.OwnerReference
- func (c *ControlPlane) EtcdImageData() (string, string)
- func (c *ControlPlane) FailureDomainWithFewestMachines() *string
- func (c *ControlPlane) FailureDomainWithMostMachines(machines FilterableMachineCollection) *string
- func (c *ControlPlane) FailureDomains() clusterv1.FailureDomains
- func (c *ControlPlane) GenerateKubeadmConfig(spec *bootstrapv1.KubeadmConfigSpec) *bootstrapv1.KubeadmConfig
- func (c *ControlPlane) HasDeletingMachine() bool
- func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference
- func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec
- func (c *ControlPlane) JoinControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec
- func (c *ControlPlane) Logger() logr.Logger
- func (c *ControlPlane) MachineInFailureDomainWithMostMachines(machines FilterableMachineCollection) (*clusterv1.Machine, error)
- func (c *ControlPlane) NeedsReplacementNode() bool
- func (c *ControlPlane) NewMachine(infraRef, bootstrapRef *corev1.ObjectReference, failureDomain *string) *clusterv1.Machine
- func (c *ControlPlane) Version() *string
- type CoreDNSMigrator
- type FilterableMachineCollection
- func (s FilterableMachineCollection) AnyFilter(filters ...machinefilters.Func) FilterableMachineCollection
- func (s FilterableMachineCollection) ConditionGetters() []conditions.Getter
- func (s FilterableMachineCollection) DeepCopy() FilterableMachineCollection
- func (s FilterableMachineCollection) Filter(filters ...machinefilters.Func) FilterableMachineCollection
- func (s FilterableMachineCollection) Insert(machines ...*clusterv1.Machine) FilterableMachineCollection
- func (s FilterableMachineCollection) Len() int
- func (s FilterableMachineCollection) Newest() *clusterv1.Machine
- func (s FilterableMachineCollection) Oldest() *clusterv1.Machine
- func (s FilterableMachineCollection) SortedByCreationTimestamp() []*clusterv1.Machine
- type HealthCheckResult
- type Management
- func (m *Management) Get(ctx context.Context, key ctrlclient.ObjectKey, obj runtime.Object) error
- func (m *Management) GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...machinefilters.Func) (FilterableMachineCollection, error)
- func (m *Management) GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey) (WorkloadCluster, error)
- func (m *Management) List(ctx context.Context, list runtime.Object, opts ...ctrlclient.ListOption) error
- func (m *Management) TargetClusterControlPlaneIsHealthy(ctx context.Context, clusterKey client.ObjectKey) error
- func (m *Management) TargetClusterEtcdIsHealthy(ctx context.Context, clusterKey client.ObjectKey) error
- type ManagementCluster
- type RemoteClusterConnectionError
- type Workload
- func (w *Workload) AllowBootstrapTokensToGetNodes(ctx context.Context) error
- func (w *Workload) ClusterStatus(ctx context.Context) (ClusterStatus, error)
- func (w *Workload) ControlPlaneIsHealthy(ctx context.Context) (HealthCheckResult, error)
- func (w *Workload) EnsureResource(ctx context.Context, obj runtime.Object) error
- func (w *Workload) EtcdIsHealthy(ctx context.Context) (HealthCheckResult, error)
- func (w *Workload) ForwardEtcdLeadership(ctx context.Context, machine *clusterv1.Machine, ...) error
- func (w *Workload) ReconcileEtcdMembers(ctx context.Context) error
- func (w *Workload) ReconcileKubeletRBACBinding(ctx context.Context, version semver.Version) error
- func (w *Workload) ReconcileKubeletRBACRole(ctx context.Context, version semver.Version) error
- func (w *Workload) RemoveEtcdMemberForMachine(ctx context.Context, machine *clusterv1.Machine) error
- func (w *Workload) RemoveMachineFromKubeadmConfigMap(ctx context.Context, machine *clusterv1.Machine) error
- func (w *Workload) RemoveNodeFromKubeadmConfigMap(ctx context.Context, name string) error
- func (w *Workload) UpdateCoreDNS(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error
- func (w *Workload) UpdateEtcdVersionInKubeadmConfigMap(ctx context.Context, imageRepository, imageTag string) error
- func (w *Workload) UpdateImageRepositoryInKubeadmConfigMap(ctx context.Context, imageRepository string) error
- func (w *Workload) UpdateKubeProxyImageInfo(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error
- func (w *Workload) UpdateKubeletConfigMap(ctx context.Context, version semver.Version) error
- func (w *Workload) UpdateKubernetesVersionInKubeadmConfigMap(ctx context.Context, version semver.Version) error
- type WorkloadCluster
Constants ¶
const ( // NodeBootstrapTokenAuthGroup specifies which group a Node Bootstrap Token should be authenticated in NodeBootstrapTokenAuthGroup = "system:bootstrappers:kubeadm:default-node-token" // GetNodesClusterRoleName defines the name of the ClusterRole and ClusterRoleBinding to get nodes GetNodesClusterRoleName = "kubeadm:get-nodes" // NodesGroup defines the well-known group for all nodes. NodesGroup = "system:nodes" // KubeletConfigMapRolePrefix defines base kubelet configuration ConfigMap role prefix. KubeletConfigMapRolePrefix = "kubeadm:" // KubeletConfigMapName defines base kubelet configuration ConfigMap name. KubeletConfigMapName = "kubelet-config-%d.%d" )
Variables ¶
var (
ErrControlPlaneMinNodes = errors.New("cluster has fewer than 2 control plane nodes; removing an etcd member is not supported")
)
var Log = klogr.New()
Log is the global logger for the internal package.
Functions ¶
func ControlPlaneLabelsForCluster ¶
ControlPlaneLabelsForCluster returns a set of labels to add to a control plane machine for this specific cluster.
func PickFewest ¶
func PickFewest(failureDomains clusterv1.FailureDomains, machines FilterableMachineCollection) *string
PickFewest returns the failure domain with the fewest number of machines.
func PickMost ¶
func PickMost(c *ControlPlane, machines FilterableMachineCollection) *string
PickMost returns a failure domain that is in machines and has most control-plane machines on.
Types ¶
type ClusterStatus ¶
type ClusterStatus struct { // Nodes are a total count of nodes Nodes int32 // ReadyNodes are the count of nodes that are reporting ready ReadyNodes int32 // HasKubeadmConfig will be true if the kubeadm config map has been uploaded, false otherwise. HasKubeadmConfig bool }
ClusterStatus holds stats information about the cluster.
type ControlPlane ¶ added in v0.3.2
type ControlPlane struct { KCP *controlplanev1.KubeadmControlPlane Cluster *clusterv1.Cluster Machines FilterableMachineCollection }
ControlPlane holds business logic around control planes. It should never need to connect to a service, that responsibility lies outside of this struct.
func NewControlPlane ¶ added in v0.3.2
func NewControlPlane(cluster *clusterv1.Cluster, kcp *controlplanev1.KubeadmControlPlane, ownedMachines FilterableMachineCollection) *ControlPlane
NewControlPlane returns an instantiated ControlPlane.
func (*ControlPlane) AsOwnerReference ¶ added in v0.3.2
func (c *ControlPlane) AsOwnerReference() *metav1.OwnerReference
AsOwnerReference returns an owner reference to the KubeadmControlPlane.
func (*ControlPlane) EtcdImageData ¶ added in v0.3.2
func (c *ControlPlane) EtcdImageData() (string, string)
EtcdImageData returns the etcd image data embedded in the ClusterConfiguration or empty strings if none are defined.
func (*ControlPlane) FailureDomainWithFewestMachines ¶ added in v0.3.3
func (c *ControlPlane) FailureDomainWithFewestMachines() *string
FailureDomainWithFewestMachines returns the failure domain with the fewest number of machines. Used when scaling up.
func (*ControlPlane) FailureDomainWithMostMachines ¶ added in v0.3.3
func (c *ControlPlane) FailureDomainWithMostMachines(machines FilterableMachineCollection) *string
FailureDomainWithMostMachines returns a fd which exists both in machines and control-plane machines and has the most control-plane machines on it.
func (*ControlPlane) FailureDomains ¶ added in v0.3.3
func (c *ControlPlane) FailureDomains() clusterv1.FailureDomains
FailureDomains returns a slice of failure domain objects synced from the infrastructure provider into Cluster.Status.
func (*ControlPlane) GenerateKubeadmConfig ¶ added in v0.3.2
func (c *ControlPlane) GenerateKubeadmConfig(spec *bootstrapv1.KubeadmConfigSpec) *bootstrapv1.KubeadmConfig
GenerateKubeadmConfig generates a new kubeadm config for creating new control plane nodes.
func (*ControlPlane) HasDeletingMachine ¶ added in v0.3.2
func (c *ControlPlane) HasDeletingMachine() bool
HasDeletingMachine returns true if any machine in the control plane is in the process of being deleted.
func (*ControlPlane) InfrastructureTemplate ¶ added in v0.3.2
func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference
InfrastructureTemplate returns the KubeadmControlPlane's infrastructure template.
func (*ControlPlane) InitialControlPlaneConfig ¶ added in v0.3.2
func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec
InitialControlPlaneConfig returns a new KubeadmConfigSpec that is to be used for an initializing control plane.
func (*ControlPlane) JoinControlPlaneConfig ¶ added in v0.3.2
func (c *ControlPlane) JoinControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec
JoinControlPlaneConfig returns a new KubeadmConfigSpec that is to be used for joining control planes.
func (*ControlPlane) Logger ¶ added in v0.3.2
func (c *ControlPlane) Logger() logr.Logger
Logger returns a logger with useful context.
func (*ControlPlane) MachineInFailureDomainWithMostMachines ¶ added in v0.3.4
func (c *ControlPlane) MachineInFailureDomainWithMostMachines(machines FilterableMachineCollection) (*clusterv1.Machine, error)
MachineInFailureDomainWithMostMachines returns the first matching failure domain with machines that has the most control-plane machines on it.
func (*ControlPlane) NeedsReplacementNode ¶ added in v0.3.2
func (c *ControlPlane) NeedsReplacementNode() bool
NeedsReplacementNode determines if the control plane needs to create a replacement node during upgrade.
func (*ControlPlane) NewMachine ¶ added in v0.3.2
func (c *ControlPlane) NewMachine(infraRef, bootstrapRef *corev1.ObjectReference, failureDomain *string) *clusterv1.Machine
NewMachine returns a machine configured to be a part of the control plane.
func (*ControlPlane) Version ¶ added in v0.3.2
func (c *ControlPlane) Version() *string
Version returns the KubeadmControlPlane's version.
type CoreDNSMigrator ¶
type CoreDNSMigrator struct{}
type FilterableMachineCollection ¶
FilterableMachineCollection is a set of Machines
func NewFilterableMachineCollection ¶
func NewFilterableMachineCollection(machines ...*clusterv1.Machine) FilterableMachineCollection
NewFilterableMachineCollection creates a FilterableMachineCollection from a list of values.
func NewFilterableMachineCollectionFromMachineList ¶
func NewFilterableMachineCollectionFromMachineList(machineList *clusterv1.MachineList) FilterableMachineCollection
NewFilterableMachineCollectionFromMachineList creates a FilterableMachineCollection from the given MachineList
func (FilterableMachineCollection) AnyFilter ¶
func (s FilterableMachineCollection) AnyFilter(filters ...machinefilters.Func) FilterableMachineCollection
AnyFilter returns a FilterableMachineCollection containing only the Machines that match any of the given MachineFilters
func (FilterableMachineCollection) ConditionGetters ¶ added in v0.3.7
func (s FilterableMachineCollection) ConditionGetters() []conditions.Getter
ConditionGetters returns the slice with machines converted into conditions.Getter.
func (FilterableMachineCollection) DeepCopy ¶
func (s FilterableMachineCollection) DeepCopy() FilterableMachineCollection
DeepCopy returns a deep copy
func (FilterableMachineCollection) Filter ¶
func (s FilterableMachineCollection) Filter(filters ...machinefilters.Func) FilterableMachineCollection
Filter returns a FilterableMachineCollection containing only the Machines that match all of the given MachineFilters
func (FilterableMachineCollection) Insert ¶
func (s FilterableMachineCollection) Insert(machines ...*clusterv1.Machine) FilterableMachineCollection
Insert adds items to the set.
func (FilterableMachineCollection) Len ¶
func (s FilterableMachineCollection) Len() int
Len returns the size of the set.
func (FilterableMachineCollection) Newest ¶ added in v0.3.2
func (s FilterableMachineCollection) Newest() *clusterv1.Machine
Newest returns the Machine with the most recent CreationTimestamp
func (FilterableMachineCollection) Oldest ¶
func (s FilterableMachineCollection) Oldest() *clusterv1.Machine
Oldest returns the Machine with the oldest CreationTimestamp
func (FilterableMachineCollection) SortedByCreationTimestamp ¶ added in v0.3.2
func (s FilterableMachineCollection) SortedByCreationTimestamp() []*clusterv1.Machine
SortedByCreationTimestamp returns the machines sorted by creation timestamp
type HealthCheckResult ¶
HealthCheckResult maps nodes that are checked to any errors the node has related to the check.
type Management ¶
type Management struct {
Client ctrlclient.Reader
}
Management holds operations on the management cluster.
func (*Management) Get ¶ added in v0.3.7
func (m *Management) Get(ctx context.Context, key ctrlclient.ObjectKey, obj runtime.Object) error
Get implements ctrlclient.Reader
func (*Management) GetMachinesForCluster ¶
func (m *Management) GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...machinefilters.Func) (FilterableMachineCollection, error)
GetMachinesForCluster returns a list of machines that can be filtered or not. If no filter is supplied then all machines associated with the target cluster are returned.
func (*Management) GetWorkloadCluster ¶
func (m *Management) GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey) (WorkloadCluster, error)
GetWorkloadCluster builds a cluster object. The cluster comes with an etcd client generator to connect to any etcd pod living on a managed machine.
func (*Management) List ¶ added in v0.3.7
func (m *Management) List(ctx context.Context, list runtime.Object, opts ...ctrlclient.ListOption) error
List implements ctrlclient.Reader
func (*Management) TargetClusterControlPlaneIsHealthy ¶
func (m *Management) TargetClusterControlPlaneIsHealthy(ctx context.Context, clusterKey client.ObjectKey) error
TargetClusterControlPlaneIsHealthy checks every node for control plane health.
func (*Management) TargetClusterEtcdIsHealthy ¶
func (m *Management) TargetClusterEtcdIsHealthy(ctx context.Context, clusterKey client.ObjectKey) error
TargetClusterEtcdIsHealthy runs a series of checks over a target cluster's etcd cluster. In addition, it verifies that there are the same number of etcd members as control plane Machines.
type ManagementCluster ¶
type ManagementCluster interface { ctrlclient.Reader GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...machinefilters.Func) (FilterableMachineCollection, error) TargetClusterEtcdIsHealthy(ctx context.Context, clusterKey client.ObjectKey) error TargetClusterControlPlaneIsHealthy(ctx context.Context, clusterKey client.ObjectKey) error GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey) (WorkloadCluster, error) }
ManagementCluster defines all behaviors necessary for something to function as a management cluster.
type RemoteClusterConnectionError ¶ added in v0.3.7
RemoteClusterConnectionError represents a failure to connect to a remote cluster
func (*RemoteClusterConnectionError) Error ¶ added in v0.3.7
func (e *RemoteClusterConnectionError) Error() string
func (*RemoteClusterConnectionError) Unwrap ¶ added in v0.3.7
func (e *RemoteClusterConnectionError) Unwrap() error
type Workload ¶
type Workload struct { Client ctrlclient.Client CoreDNSMigrator coreDNSMigrator // contains filtered or unexported fields }
Workload defines operations on workload clusters.
func (*Workload) AllowBootstrapTokensToGetNodes ¶ added in v0.3.5
AllowBootstrapTokensToGetNodes creates RBAC rules to allow Node Bootstrap Tokens to list nodes
func (*Workload) ClusterStatus ¶
func (w *Workload) ClusterStatus(ctx context.Context) (ClusterStatus, error)
ClusterStatus returns the status of the cluster.
func (*Workload) ControlPlaneIsHealthy ¶
func (w *Workload) ControlPlaneIsHealthy(ctx context.Context) (HealthCheckResult, error)
controlPlaneIsHealthy does a best effort check of the control plane components the kubeadm control plane cares about. The return map is a map of node names as keys to error that that node encountered. All nodes will exist in the map with nil errors if there were no errors for that node.
func (*Workload) EnsureResource ¶ added in v0.3.5
EnsureResource creates a resoutce if the target resource doesn't exist. If the resource exists already, this function will ignore the resource instead.
func (*Workload) EtcdIsHealthy ¶
func (w *Workload) EtcdIsHealthy(ctx context.Context) (HealthCheckResult, error)
EtcdIsHealthy runs checks for every etcd member in the cluster to satisfy our definition of healthy. This is a best effort check and nodes can become unhealthy after the check is complete. It is not a guarantee. It's used a signal for if we should allow a target cluster to scale up, scale down or upgrade. It returns a map of nodes checked along with an error for a given node.
func (*Workload) ForwardEtcdLeadership ¶ added in v0.3.2
func (w *Workload) ForwardEtcdLeadership(ctx context.Context, machine *clusterv1.Machine, leaderCandidate *clusterv1.Machine) error
ForwardEtcdLeadership forwards etcd leadership to the first follower
func (*Workload) ReconcileEtcdMembers ¶ added in v0.3.4
ReconcileEtcdMembers iterates over all etcd members and finds members that do not have corresponding nodes. If there are any such members, it deletes them from etcd and removes their nodes from the kubeadm configmap so that kubeadm does not run etcd health checks on them.
func (*Workload) ReconcileKubeletRBACBinding ¶
ReconcileKubeletRBACBinding will create a RoleBinding for the new kubelet version during upgrades. If the role binding already exists this function is a no-op.
func (*Workload) ReconcileKubeletRBACRole ¶
ReconcileKubeletRBACRole will create a Role for the new kubelet version during upgrades. If the role already exists this function is a no-op.
func (*Workload) RemoveEtcdMemberForMachine ¶
func (w *Workload) RemoveEtcdMemberForMachine(ctx context.Context, machine *clusterv1.Machine) error
RemoveEtcdMemberForMachine removes the etcd member from the target cluster's etcd cluster. Removing the last remaining member of the cluster is not supported.
func (*Workload) RemoveMachineFromKubeadmConfigMap ¶
func (w *Workload) RemoveMachineFromKubeadmConfigMap(ctx context.Context, machine *clusterv1.Machine) error
RemoveMachineFromKubeadmConfigMap removes the entry for the machine from the kubeadm configmap.
func (*Workload) RemoveNodeFromKubeadmConfigMap ¶ added in v0.3.4
RemoveNodeFromKubeadmConfigMap removes the entry for the node from the kubeadm configmap.
func (*Workload) UpdateCoreDNS ¶
func (w *Workload) UpdateCoreDNS(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error
UpdateCoreDNS updates the kubeadm configmap, coredns corefile and coredns deployment.
func (*Workload) UpdateEtcdVersionInKubeadmConfigMap ¶
func (w *Workload) UpdateEtcdVersionInKubeadmConfigMap(ctx context.Context, imageRepository, imageTag string) error
UpdateEtcdVersionInKubeadmConfigMap sets the imageRepository or the imageTag or both in the kubeadm config map.
func (*Workload) UpdateImageRepositoryInKubeadmConfigMap ¶ added in v0.3.3
func (w *Workload) UpdateImageRepositoryInKubeadmConfigMap(ctx context.Context, imageRepository string) error
UpdateKubernetesVersionInKubeadmConfigMap updates the kubernetes version in the kubeadm config map.
func (*Workload) UpdateKubeProxyImageInfo ¶
func (w *Workload) UpdateKubeProxyImageInfo(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error
UpdateKubeProxyImageInfo updates kube-proxy image in the kube-proxy DaemonSet.
func (*Workload) UpdateKubeletConfigMap ¶
UpdateKubeletConfigMap will create a new kubelet-config-1.x config map for a new version of the kubelet. This is a necessary process for upgrades.
type WorkloadCluster ¶
type WorkloadCluster interface { // Basic health and status checks. ClusterStatus(ctx context.Context) (ClusterStatus, error) ControlPlaneIsHealthy(ctx context.Context) (HealthCheckResult, error) EtcdIsHealthy(ctx context.Context) (HealthCheckResult, error) // Upgrade related tasks. ReconcileKubeletRBACBinding(ctx context.Context, version semver.Version) error ReconcileKubeletRBACRole(ctx context.Context, version semver.Version) error UpdateKubernetesVersionInKubeadmConfigMap(ctx context.Context, version semver.Version) error UpdateImageRepositoryInKubeadmConfigMap(ctx context.Context, imageRepository string) error UpdateEtcdVersionInKubeadmConfigMap(ctx context.Context, imageRepository, imageTag string) error UpdateKubeletConfigMap(ctx context.Context, version semver.Version) error UpdateKubeProxyImageInfo(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error UpdateCoreDNS(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error RemoveEtcdMemberForMachine(ctx context.Context, machine *clusterv1.Machine) error RemoveMachineFromKubeadmConfigMap(ctx context.Context, machine *clusterv1.Machine) error RemoveNodeFromKubeadmConfigMap(ctx context.Context, nodeName string) error ForwardEtcdLeadership(ctx context.Context, machine *clusterv1.Machine, leaderCandidate *clusterv1.Machine) error AllowBootstrapTokensToGetNodes(ctx context.Context) error // State recovery tasks. ReconcileEtcdMembers(ctx context.Context) error }
WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster