import "sigs.k8s.io/cluster-api/controlplane/kubeadm/internal"
cluster.go cluster_labels.go control_plane.go etcd_client_generator.go failure_domain.go kubeadm_config_map.go machine_collection.go workload_cluster.go workload_cluster_conditions.go workload_cluster_coredns.go workload_cluster_etcd.go workload_cluster_rbac.go
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" )
var ( ErrControlPlaneMinNodes = errors.New("cluster has fewer than 2 control plane nodes; removing an etcd member is not supported") )
Log is the global logger for the internal package.
ControlPlaneLabelsForCluster returns a set of labels to add to a control plane machine for this specific cluster.
NewEtcdClientGenerator returns a new etcdClientGenerator instance.
func PickFewest(failureDomains clusterv1.FailureDomains, machines FilterableMachineCollection) *string
PickFewest returns the failure domain with the fewest number of machines.
func PickMost(c *ControlPlane, machines FilterableMachineCollection) *string
PickMost returns a failure domain that is in machines and has most control-plane machines on.
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 struct { KCP *controlplanev1.KubeadmControlPlane Cluster *clusterv1.Cluster Machines FilterableMachineCollection // contains filtered or unexported fields }
ControlPlane holds business logic around control planes. It should never need to connect to a service, that responsibility lies outside of this struct. Going forward we should be trying to add more logic to here and reduce the amount of logic in the reconciler.
func NewControlPlane(ctx context.Context, client client.Client, cluster *clusterv1.Cluster, kcp *controlplanev1.KubeadmControlPlane, ownedMachines FilterableMachineCollection) (*ControlPlane, error)
NewControlPlane returns an instantiated ControlPlane.
func (c *ControlPlane) AsOwnerReference() *metav1.OwnerReference
AsOwnerReference returns an owner reference to the KubeadmControlPlane.
func (c *ControlPlane) EtcdImageData() (string, string)
EtcdImageData returns the etcd image data embedded in the ClusterConfiguration or empty strings if none are defined.
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 (c *ControlPlane) FailureDomains() clusterv1.FailureDomains
FailureDomains returns a slice of failure domain objects synced from the infrastructure provider into Cluster.Status.
func (c *ControlPlane) GenerateKubeadmConfig(spec *bootstrapv1.KubeadmConfigSpec) *bootstrapv1.KubeadmConfig
GenerateKubeadmConfig generates a new kubeadm config for creating new control plane nodes.
func (c *ControlPlane) HasDeletingMachine() bool
HasDeletingMachine returns true if any machine in the control plane is in the process of being deleted.
func (c *ControlPlane) HasUnhealthyMachine() bool
HasUnhealthyMachine returns true if any machine in the control plane is marked as unhealthy by MHC.
func (c *ControlPlane) HealthyMachines() FilterableMachineCollection
HealthyMachines returns the list of control plane machines not marked as unhealthy by MHC.
func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference
InfrastructureTemplate returns the KubeadmControlPlane's infrastructure template.
func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec
InitialControlPlaneConfig returns a new KubeadmConfigSpec that is to be used for an initializing control plane.
func (c *ControlPlane) IsEtcdManaged() bool
IsEtcdManaged returns true if the control plane relies on a managed etcd.
func (c *ControlPlane) JoinControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec
JoinControlPlaneConfig returns a new KubeadmConfigSpec that is to be used for joining control planes.
func (c *ControlPlane) Logger() logr.Logger
Logger returns a logger with useful context.
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 (c *ControlPlane) MachineWithDeleteAnnotation(machines FilterableMachineCollection) FilterableMachineCollection
MachineWithDeleteAnnotation returns a machine that has been annotated with DeleteMachineAnnotation key.
func (c *ControlPlane) MachinesNeedingRollout() FilterableMachineCollection
MachinesNeedingRollout return a list of machines that need to be rolled out.
func (c *ControlPlane) NeedsReplacementNode() bool
NeedsReplacementNode determines if the control plane needs to create a replacement node during upgrade.
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 (c *ControlPlane) NextFailureDomainForScaleUp() *string
NextFailureDomainForScaleUp returns the failure domain with the fewest number of up-to-date machines.
func (c *ControlPlane) PatchMachines(ctx context.Context) error
func (c *ControlPlane) UnhealthyMachines() FilterableMachineCollection
UnhealthyMachines returns the list of control plane machines marked as unhealthy by MHC.
func (c *ControlPlane) UpToDateMachines() FilterableMachineCollection
UpToDateMachines returns the machines that are up to date with the control plane's configuration and therefore do not require rollout.
func (c *ControlPlane) Version() *string
Version returns the KubeadmControlPlane's version.
type CoreDNSMigrator struct{}
func (c *CoreDNSMigrator) Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefile string, deprecations bool) (string, error)
FilterableMachineCollection is a set of Machines
func NewFilterableMachineCollection(machines ...*clusterv1.Machine) FilterableMachineCollection
NewFilterableMachineCollection creates a FilterableMachineCollection from a list of values.
func NewFilterableMachineCollectionFromMachineList(machineList *clusterv1.MachineList) FilterableMachineCollection
NewFilterableMachineCollectionFromMachineList creates a FilterableMachineCollection from the given MachineList
func (s FilterableMachineCollection) AnyFilter(filters ...machinefilters.Func) FilterableMachineCollection
AnyFilter returns a FilterableMachineCollection containing only the Machines that match any of the given MachineFilters
func (s FilterableMachineCollection) ConditionGetters() []conditions.Getter
ConditionGetters returns the slice with machines converted into conditions.Getter.
func (s FilterableMachineCollection) DeepCopy() FilterableMachineCollection
DeepCopy returns a deep copy
func (s FilterableMachineCollection) Difference(machines FilterableMachineCollection) FilterableMachineCollection
Difference returns a copy without machines that are in the given collection
func (s FilterableMachineCollection) Filter(filters ...machinefilters.Func) FilterableMachineCollection
Filter returns a FilterableMachineCollection containing only the Machines that match all of the given MachineFilters
func (s FilterableMachineCollection) Insert(machines ...*clusterv1.Machine)
Insert adds items to the set.
func (s FilterableMachineCollection) Len() int
Len returns the size of the set.
func (s FilterableMachineCollection) Names() []string
Names returns a slice of the names of each machine in the collection. Useful for logging and test assertions.
func (s FilterableMachineCollection) Newest() *clusterv1.Machine
Newest returns the Machine with the most recent CreationTimestamp
func (s FilterableMachineCollection) Oldest() *clusterv1.Machine
Oldest returns the Machine with the oldest CreationTimestamp
func (s FilterableMachineCollection) SortedByCreationTimestamp() []*clusterv1.Machine
SortedByCreationTimestamp returns the machines sorted by creation timestamp
func (s FilterableMachineCollection) UnsortedList() []*clusterv1.Machine
UnsortedList returns the slice with contents in random order.
type Management struct { Client ctrlclient.Reader }
Management holds operations on the management cluster.
func (m *Management) Get(ctx context.Context, key ctrlclient.ObjectKey, obj client.Object) error
Get implements ctrlclient.Reader
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 (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 (m *Management) List(ctx context.Context, list client.ObjectList, opts ...ctrlclient.ListOption) error
List implements ctrlclient.Reader
type ManagementCluster interface { ctrlclient.Reader GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...machinefilters.Func) (FilterableMachineCollection, error) GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey) (WorkloadCluster, error) }
ManagementCluster defines all behaviors necessary for something to function as a management cluster.
RemoteClusterConnectionError represents a failure to connect to a remote cluster
func (e *RemoteClusterConnectionError) Error() string
func (e *RemoteClusterConnectionError) Unwrap() error
type Workload struct { Client ctrlclient.Client CoreDNSMigrator coreDNSMigrator // contains filtered or unexported fields }
Workload defines operations on workload clusters.
AllowBootstrapTokensToGetNodes creates RBAC rules to allow Node Bootstrap Tokens to list nodes
ClusterStatus returns the status of the cluster.
EnsureResource creates a resoutce if the target resource doesn't exist. If the resource exists already, this function will ignore the resource instead.
EtcdStatus returns the current status of the etcd cluster NOTE: This methods uses control plane machines/nodes only to get in contact with etcd, but then it relies on etcd as ultimate source of truth for the list of members. This is intended to allow informed decisions on actions impacting etcd quorum.
func (w *Workload) ForwardEtcdLeadership(ctx context.Context, machine *clusterv1.Machine, leaderCandidate *clusterv1.Machine) error
ForwardEtcdLeadership forwards etcd leadership to the first follower
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.
ReconcileKubeletRBACBinding will create a RoleBinding for the new kubelet version during upgrades. If the role binding already exists this function is a no-op.
ReconcileKubeletRBACRole will create a Role for the new kubelet version during upgrades. If the role already exists this function is a no-op.
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 (w *Workload) RemoveMachineFromKubeadmConfigMap(ctx context.Context, machine *clusterv1.Machine) error
RemoveMachineFromKubeadmConfigMap removes the entry for the machine from the kubeadm configmap.
RemoveNodeFromKubeadmConfigMap removes the entry for the node from the kubeadm configmap.
func (w *Workload) UpdateAPIServerInKubeadmConfigMap(ctx context.Context, apiServer kubeadmv1.APIServer) error
UpdateAPIServerInKubeadmConfigMap updates api server configuration in kubeadm config map.
func (w *Workload) UpdateControllerManagerInKubeadmConfigMap(ctx context.Context, controllerManager kubeadmv1.ControlPlaneComponent) error
UpdateControllerManagerInKubeadmConfigMap updates controller manager configuration in kubeadm config map.
func (w *Workload) UpdateCoreDNS(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error
UpdateCoreDNS updates the kubeadm configmap, coredns corefile and coredns deployment.
func (w *Workload) UpdateEtcdConditions(ctx context.Context, controlPlane *ControlPlane)
UpdateEtcdConditions is responsible for updating machine conditions reflecting the status of all the etcd members. This operation is best effort, in the sense that in case of problems in retrieving member status, it sets the condition to Unknown state without returning any error.
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 (w *Workload) UpdateImageRepositoryInKubeadmConfigMap(ctx context.Context, imageRepository string) error
UpdateKubernetesVersionInKubeadmConfigMap updates the kubernetes version in the kubeadm config map.
func (w *Workload) UpdateKubeProxyImageInfo(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error
UpdateKubeProxyImageInfo updates kube-proxy image in the kube-proxy DaemonSet.
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.
func (w *Workload) UpdateKubernetesVersionInKubeadmConfigMap(ctx context.Context, version semver.Version) error
UpdateKubernetesVersionInKubeadmConfigMap updates the kubernetes version in the kubeadm config map.
func (w *Workload) UpdateSchedulerInKubeadmConfigMap(ctx context.Context, scheduler kubeadmv1.ControlPlaneComponent) error
UpdateSchedulerInKubeadmConfigMap updates scheduler configuration in kubeadm config map.
func (w *Workload) UpdateStaticPodConditions(ctx context.Context, controlPlane *ControlPlane)
UpdateStaticPodConditions is responsible for updating machine conditions reflecting the status of all the control plane components running in a static pod generated by kubeadm. This operation is best effort, in the sense that in case of problems in retrieving the pod status, it sets the condition to Unknown state without returning any error.
type WorkloadCluster interface { // Basic health and status checks. ClusterStatus(ctx context.Context) (ClusterStatus, error) UpdateStaticPodConditions(ctx context.Context, controlPlane *ControlPlane) UpdateEtcdConditions(ctx context.Context, controlPlane *ControlPlane) EtcdMembers(ctx context.Context) ([]string, 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 UpdateAPIServerInKubeadmConfigMap(ctx context.Context, apiServer kubeadmv1.APIServer) error UpdateControllerManagerInKubeadmConfigMap(ctx context.Context, controllerManager kubeadmv1.ControlPlaneComponent) error UpdateSchedulerInKubeadmConfigMap(ctx context.Context, scheduler kubeadmv1.ControlPlaneComponent) 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, nodeNames []string) ([]string, error) }
WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster
TODO: Add a detailed description to each of these method definitions.
Path | Synopsis |
---|---|
etcd | Package etcd provides a connection to an etcd member. |
etcd/fake | |
etcd/util | |
hash | |
machinefilters | |
proxy |
Package internal imports 49 packages (graph) and is imported by 1 packages. Updated 2021-01-19. Refresh now. Tools for package owners.