Documentation
¶
Index ¶
- Constants
- Variables
- func ControlPlaneLabelsForCluster(clusterName string, ...) map[string]string
- func GenerateInitControlPlaneConfig(cfg InitControlPlaneConfig) (apiv1.BootstrapConfig, error)
- func GenerateJoinControlPlaneConfig(cfg JoinControlPlaneConfig) apiv1.ControlPlaneJoinConfig
- func GenerateJoinWorkerConfig(cfg JoinWorkerConfig) apiv1.WorkerJoinConfig
- func NewK8sdClientGenerator(restConfig *rest.Config, proxyClientTimeout time.Duration) (*k8sdClientGenerator, error)
- func RenderK8sdProxyDaemonSetManifest(input K8sdProxyDaemonSetInput) ([]byte, error)
- type ClusterStatus
- type ControlPlane
- func (c *ControlPlane) AsOwnerReference() *metav1.OwnerReference
- func (c *ControlPlane) EtcdImageData() (string, string)
- func (c *ControlPlane) FailureDomainWithMostMachines(ctx context.Context, machines collections.Machines) *string
- func (c *ControlPlane) FailureDomains() clusterv1.FailureDomains
- func (c *ControlPlane) GenerateCK8sConfig(spec *bootstrapv1.CK8sConfigSpec) *bootstrapv1.CK8sConfig
- func (c *ControlPlane) HasDeletingMachine() bool
- func (c *ControlPlane) HasHealthyMachineStillProvisioning() bool
- func (c *ControlPlane) HasUnhealthyMachine() bool
- func (c *ControlPlane) HealthyMachines() collections.Machines
- func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference
- func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.CK8sConfigSpec
- func (c *ControlPlane) IsEtcdManaged() bool
- func (c *ControlPlane) JoinControlPlaneConfig() *bootstrapv1.CK8sConfigSpec
- func (c *ControlPlane) MachineInFailureDomainWithMostMachines(ctx context.Context, machines collections.Machines) (*clusterv1.Machine, error)
- func (c *ControlPlane) MachineWithDeleteAnnotation(machines collections.Machines) collections.Machines
- func (c *ControlPlane) MachinesNeedingRollout() collections.Machines
- func (c *ControlPlane) NeedsReplacementNode() bool
- func (c *ControlPlane) NewMachine(infraRef, bootstrapRef *corev1.ObjectReference, failureDomain *string) *clusterv1.Machine
- func (c *ControlPlane) NextFailureDomainForScaleUp(ctx context.Context) *string
- func (c *ControlPlane) PatchMachines(ctx context.Context) error
- func (c *ControlPlane) UnhealthyMachines() collections.Machines
- func (c *ControlPlane) UpToDateMachines() collections.Machines
- func (c *ControlPlane) Version() *string
- type InitControlPlaneConfig
- type JoinControlPlaneConfig
- type JoinWorkerConfig
- type K8sdClient
- type K8sdProxyDaemonSetInput
- type Management
- func (m *Management) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (m *Management) GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...collections.Func) (collections.Machines, error)
- func (m *Management) GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey, microclusterPort int) (*Workload, error)
- func (m *Management) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- type ManagementCluster
- type RemoteClusterConnectionError
- type Workload
- func (w *Workload) ApproveCertificates(ctx context.Context, machine *clusterv1.Machine, seed int) error
- func (w *Workload) ClusterStatus(ctx context.Context) (ClusterStatus, error)
- func (w *Workload) GetCertificatesExpiryDate(ctx context.Context, machine *clusterv1.Machine, nodeToken string) (string, error)
- func (w *Workload) GetK8sdProxyForControlPlane(ctx context.Context, options k8sdProxyOptions) (*K8sdClient, error)
- func (w *Workload) GetK8sdProxyForMachine(ctx context.Context, machine *clusterv1.Machine) (*K8sdClient, error)
- func (w *Workload) GetRefreshStatusForMachine(ctx context.Context, machine *clusterv1.Machine, nodeToken string, ...) (*apiv1.SnapRefreshStatusResponse, error)
- func (w *Workload) NewControlPlaneJoinToken(ctx context.Context, name string) (string, error)
- func (w *Workload) NewWorkerJoinToken(ctx context.Context) (string, error)
- func (w *Workload) RefreshControlPlaneCertificates(ctx context.Context, machine *clusterv1.Machine, nodeToken string, ...) (int, error)
- func (w *Workload) RefreshMachine(ctx context.Context, machine *clusterv1.Machine, nodeToken string, ...) (string, error)
- func (w *Workload) RefreshWorkerCertificates(ctx context.Context, machine *clusterv1.Machine, nodeToken string, ...) (int, error)
- func (w *Workload) RemoveMachineFromCluster(ctx context.Context, machine *clusterv1.Machine) error
- func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *ControlPlane)
- type WorkloadCluster
Constants ¶
const (
// CK8sControlPlaneControllerName defines the controller used when creating clients.
CK8sControlPlaneControllerName = "ck8s-controlplane-controller"
)
Variables ¶
var ( ErrFailedToPickForDeletion = errors.New("failed to pick machine to mark for deletion") ErrFailedToCreatePatchHelper = errors.New("failed to create patch for machine") )
Functions ¶
func ControlPlaneLabelsForCluster ¶
func ControlPlaneLabelsForCluster(clusterName string, machineTemplate controlplanev1.CK8sControlPlaneMachineTemplate) map[string]string
ControlPlaneLabelsForCluster returns a set of labels to add to a control plane machine for this specific cluster.
func GenerateInitControlPlaneConfig ¶
func GenerateInitControlPlaneConfig(cfg InitControlPlaneConfig) (apiv1.BootstrapConfig, error)
func GenerateJoinControlPlaneConfig ¶
func GenerateJoinControlPlaneConfig(cfg JoinControlPlaneConfig) apiv1.ControlPlaneJoinConfig
func GenerateJoinWorkerConfig ¶
func GenerateJoinWorkerConfig(cfg JoinWorkerConfig) apiv1.WorkerJoinConfig
func NewK8sdClientGenerator ¶
func RenderK8sdProxyDaemonSetManifest ¶
func RenderK8sdProxyDaemonSetManifest(input K8sdProxyDaemonSetInput) ([]byte, error)
RenderK8sdProxyDaemonSet renders the manifest for the k8sd-proxy daemonset based on supplied configuration.
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 // HasK8sdConfigMap will be true if the k8sd-config configmap has been uploaded, false otherwise. HasK8sdConfigMap bool }
ClusterStatus holds stats information about the cluster.
type ControlPlane ¶
type ControlPlane struct { KCP *controlplanev1.CK8sControlPlane Cluster *clusterv1.Cluster Machines collections.Machines // 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 ¶
func NewControlPlane(ctx context.Context, client client.Client, cluster *clusterv1.Cluster, kcp *controlplanev1.CK8sControlPlane, ownedMachines collections.Machines) (*ControlPlane, error)
NewControlPlane returns an instantiated ControlPlane.
func (*ControlPlane) AsOwnerReference ¶
func (c *ControlPlane) AsOwnerReference() *metav1.OwnerReference
AsOwnerReference returns an owner reference to the CK8sControlPlane.
func (*ControlPlane) EtcdImageData ¶
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) FailureDomainWithMostMachines ¶
func (c *ControlPlane) FailureDomainWithMostMachines(ctx context.Context, machines collections.Machines) *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 ¶
func (c *ControlPlane) FailureDomains() clusterv1.FailureDomains
FailureDomains returns a slice of failure domain objects synced from the infrastructure provider into Cluster.Status.
func (*ControlPlane) GenerateCK8sConfig ¶
func (c *ControlPlane) GenerateCK8sConfig(spec *bootstrapv1.CK8sConfigSpec) *bootstrapv1.CK8sConfig
GenerateCK8sConfig generates a new CK8sConfig config for creating new control plane nodes.
func (*ControlPlane) HasDeletingMachine ¶
func (c *ControlPlane) HasDeletingMachine() bool
HasDeletingMachine returns true if any machine in the control plane is in the process of being deleted.
func (*ControlPlane) HasHealthyMachineStillProvisioning ¶
func (c *ControlPlane) HasHealthyMachineStillProvisioning() bool
HasHealthyMachineStillProvisioning returns true if any healthy machine in the control plane is still in the process of being provisioned.
func (*ControlPlane) HasUnhealthyMachine ¶
func (c *ControlPlane) HasUnhealthyMachine() bool
HasUnhealthyMachine returns true if any machine in the control plane is marked as unhealthy by MHC.
func (*ControlPlane) HealthyMachines ¶
func (c *ControlPlane) HealthyMachines() collections.Machines
HealthyMachines returns the list of control plane machines not marked as unhealthy by MHC.
func (*ControlPlane) InfrastructureTemplate ¶
func (c *ControlPlane) InfrastructureTemplate() *corev1.ObjectReference
InfrastructureTemplate returns the CK8sControlPlane's infrastructure template.
func (*ControlPlane) InitialControlPlaneConfig ¶
func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.CK8sConfigSpec
InitialControlPlaneConfig returns a new CK8sConfigSpec that is to be used for an initializing control plane.
func (*ControlPlane) IsEtcdManaged ¶
func (c *ControlPlane) IsEtcdManaged() bool
IsEtcdManaged returns true if the control plane relies on a managed k8s-dqlite.
func (*ControlPlane) JoinControlPlaneConfig ¶
func (c *ControlPlane) JoinControlPlaneConfig() *bootstrapv1.CK8sConfigSpec
JoinControlPlaneConfig returns a new CK8sConfigSpec that is to be used for joining control planes.
func (*ControlPlane) MachineInFailureDomainWithMostMachines ¶
func (c *ControlPlane) MachineInFailureDomainWithMostMachines(ctx context.Context, machines collections.Machines) (*clusterv1.Machine, error)
MachineInFailureDomainWithMostMachines returns the first matching failure domain with machines that has the most control-plane machines on it.
func (*ControlPlane) MachineWithDeleteAnnotation ¶
func (c *ControlPlane) MachineWithDeleteAnnotation(machines collections.Machines) collections.Machines
MachineWithDeleteAnnotation returns a machine that has been annotated with DeleteMachineAnnotation key.
func (*ControlPlane) MachinesNeedingRollout ¶
func (c *ControlPlane) MachinesNeedingRollout() collections.Machines
MachinesNeedingRollout return a list of machines that need to be rolled out.
func (*ControlPlane) NeedsReplacementNode ¶
func (c *ControlPlane) NeedsReplacementNode() bool
NeedsReplacementNode determines if the control plane needs to create a replacement node during upgrade.
func (*ControlPlane) NewMachine ¶
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) NextFailureDomainForScaleUp ¶
func (c *ControlPlane) NextFailureDomainForScaleUp(ctx context.Context) *string
NextFailureDomainForScaleUp returns the failure domain with the fewest number of up-to-date machines.
func (*ControlPlane) PatchMachines ¶
func (c *ControlPlane) PatchMachines(ctx context.Context) error
func (*ControlPlane) UnhealthyMachines ¶
func (c *ControlPlane) UnhealthyMachines() collections.Machines
UnhealthyMachines returns the list of control plane machines marked as unhealthy by MHC.
func (*ControlPlane) UpToDateMachines ¶
func (c *ControlPlane) UpToDateMachines() collections.Machines
UpToDateMachines returns the machines that are up to date with the control plane's configuration and therefore do not require rollout.
func (*ControlPlane) Version ¶
func (c *ControlPlane) Version() *string
Version returns the CK8sControlPlane's version.
type InitControlPlaneConfig ¶
type InitControlPlaneConfig struct { ControlPlaneEndpoint string ControlPlaneConfig bootstrapv1.CK8sControlPlaneConfig InitConfig bootstrapv1.CK8sInitConfiguration PopulatedCertificates secret.Certificates DatastoreType string DatastoreServers []string ClusterNetwork *clusterv1.ClusterNetwork }
type JoinControlPlaneConfig ¶
type JoinControlPlaneConfig struct { ControlPlaneEndpoint string ControlPlaneConfig bootstrapv1.CK8sControlPlaneConfig ExtraKubeAPIServerArgs map[string]*string }
type JoinWorkerConfig ¶
type JoinWorkerConfig struct { }
type K8sdClient ¶
type K8sdProxyDaemonSetInput ¶
type K8sdProxyDaemonSetInput struct {
K8sdPort int
}
type Management ¶
type Management struct { ManagementCluster Client client.Client K8sdDialTimeout time.Duration }
Management holds operations on the management cluster.
func (*Management) Get ¶
func (m *Management) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
Get implements ctrlclient.Reader.
func (*Management) GetMachinesForCluster ¶
func (m *Management) GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...collections.Func) (collections.Machines, 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, microclusterPort int) (*Workload, 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 ¶
func (m *Management) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List implements ctrlclient.Reader.
type ManagementCluster ¶
type ManagementCluster interface { client.Reader GetMachinesForCluster(ctx context.Context, cluster client.ObjectKey, filters ...collections.Func) (collections.Machines, error) GetWorkloadCluster(ctx context.Context, clusterKey client.ObjectKey, microclusterPort int) (*Workload, error) }
ManagementCluster defines all behaviors necessary for something to function as a management cluster.
type RemoteClusterConnectionError ¶
RemoteClusterConnectionError represents a failure to connect to a remote cluster.
func (*RemoteClusterConnectionError) Error ¶
func (e *RemoteClusterConnectionError) Error() string
func (*RemoteClusterConnectionError) Unwrap ¶
func (e *RemoteClusterConnectionError) Unwrap() error
type Workload ¶
type Workload struct { WorkloadCluster Client ctrlclient.Client ClientRestConfig *rest.Config K8sdClientGenerator *k8sdClientGenerator // contains filtered or unexported fields }
Workload defines operations on workload clusters.
func (*Workload) ApproveCertificates ¶ added in v0.2.0
func (*Workload) ClusterStatus ¶
func (w *Workload) ClusterStatus(ctx context.Context) (ClusterStatus, error)
ClusterStatus returns the status of the cluster.
func (*Workload) GetCertificatesExpiryDate ¶ added in v0.2.0
func (*Workload) GetK8sdProxyForControlPlane ¶
func (w *Workload) GetK8sdProxyForControlPlane(ctx context.Context, options k8sdProxyOptions) (*K8sdClient, error)
GetK8sdProxyForControlPlane returns a k8sd proxy client for the control plane.
func (*Workload) GetK8sdProxyForMachine ¶ added in v0.2.0
func (w *Workload) GetK8sdProxyForMachine(ctx context.Context, machine *clusterv1.Machine) (*K8sdClient, error)
GetK8sdProxyForMachine returns a k8sd proxy client for the machine.
func (*Workload) GetRefreshStatusForMachine ¶ added in v0.2.0
func (*Workload) NewControlPlaneJoinToken ¶
NewControlPlaneJoinToken creates a new join token for a control plane node. NewControlPlaneJoinToken reaches out to the control-plane of the workload cluster via k8sd-proxy client.
func (*Workload) NewWorkerJoinToken ¶
NewWorkerJoinToken creates a new join token for a worker node. NewWorkerJoinToken reaches out to the control-plane of the workload cluster via k8sd-proxy client.
func (*Workload) RefreshControlPlaneCertificates ¶ added in v0.2.0
func (*Workload) RefreshMachine ¶ added in v0.2.0
func (*Workload) RefreshWorkerCertificates ¶ added in v0.2.0
func (w *Workload) RefreshWorkerCertificates(ctx context.Context, machine *clusterv1.Machine, nodeToken string, expirationSeconds int) (int, error)
RefreshWorkerCertificates approves the worker node CSR and refreshes the certificates. The certificate approval process follows these steps: 1. The CAPI provider calls the /x/capi/refresh-certs/plan endpoint from the worker node, which generates the CSRs and creates the CertificateSigningRequest objects in the cluster. 2. The CAPI provider then calls the /x/capi/refresh-certs/run endpoint with the seed. This endpoint waits until the CSR is approved and the certificate is signed. Note that this is a blocking call. 3. The CAPI provider calls the /x/capi/refresh-certs/approve endpoint from any control plane node to approve the CSRs. 4. The /x/capi/refresh-certs/run endpoint completes and returns once the certificate is approved and signed.
func (*Workload) RemoveMachineFromCluster ¶
func (*Workload) UpdateAgentConditions ¶
func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *ControlPlane)
UpdateAgentConditions is responsible for updating machine conditions reflecting the status of all the control plane components. 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 ¶
type WorkloadCluster interface { // Basic health and status checks. ClusterStatus(ctx context.Context) (ClusterStatus, error) UpdateAgentConditions(ctx context.Context, controlPlane *ControlPlane) NewControlPlaneJoinToken(ctx context.Context, name string) (string, error) NewWorkerJoinToken(ctx context.Context) (string, error) RemoveMachineFromCluster(ctx context.Context, machine *clusterv1.Machine) error }
WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster
TODO: Add a detailed description to each of these method definitions.