Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add v1beta2 Etcd and ControlPlaneComponents conditions to KCP #11302

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ const (
// This means that the object will go away (i.e. be removed from etcd), except if there are other
// finalizers on the object.
DeletionCompletedV1Beta2Reason = "DeletionCompleted"

// InspectionFailedV1Beta2Reason applies to a condition when inspection of the underlying object failed.
InspectionFailedV1Beta2Reason = "InspectionFailed"
)

// Conditions that will be used for the MachineSet object in v1Beta2 API version.
Expand Down
103 changes: 95 additions & 8 deletions controlplane/kubeadm/api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

// KubeadmControlPlane's Available condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// KubeadmControlPlaneAvailableV1Beta2Condition True if the control plane can be reached, EtcdClusterAvailable is true,
// KubeadmControlPlaneAvailableV1Beta2Condition True if the control plane can be reached, EtcdClusterHealthy is true,
// and CertificatesAvailable is true.
KubeadmControlPlaneAvailableV1Beta2Condition = clusterv1.AvailableV1Beta2Condition
)
Expand All @@ -40,12 +40,54 @@ const (
KubeadmControlPlaneCertificatesAvailableV1Beta2Reason = clusterv1.AvailableV1Beta2Reason
)

// KubeadmControlPlane's EtcdClusterAvailable condition and corresponding reasons that will be used in v1Beta2 API version.
// KubeadmControlPlane's EtcdClusterHealthy condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// KubeadmControlPlaneEtcdClusterAvailableV1Beta2Condition surfaces issues to the managed etcd cluster, if any.
// It is computed as aggregation of Machines's EtcdMemberHealthy (if not using an external etcd) conditions plus
// additional checks validating potential issues to etcd quorum.
KubeadmControlPlaneEtcdClusterAvailableV1Beta2Condition = "EtcdClusterAvailable"
// KubeadmControlPlaneEtcdClusterHealthyV1Beta2Condition surfaces issues to etcd cluster hosted on machines managed by this object.
// It is computed as aggregation of Machine's EtcdMemberHealthy conditions plus additional checks validating
// potential issues to etcd quorum.
// Note: this condition is not set when using an external etcd.
KubeadmControlPlaneEtcdClusterHealthyV1Beta2Condition = "EtcdClusterHealthy"

// KubeadmControlPlaneEtcdClusterInspectionFailedV1Beta2Reason documents a failure when inspecting the status of the
// etcd cluster hosted on KubeadmControlPlane controlled machines.
KubeadmControlPlaneEtcdClusterInspectionFailedV1Beta2Reason = clusterv1.InspectionFailedV1Beta2Reason

// KubeadmControlPlaneEtcdClusterHealthyV1Beta2Reason surfaces when the etcd cluster hosted on KubeadmControlPlane
// machines is healthy.
KubeadmControlPlaneEtcdClusterHealthyV1Beta2Reason = "Healthy"

// KubeadmControlPlaneEtcdClusterNotHealthyV1Beta2Reason surfaces when the etcd cluster hosted on KubeadmControlPlane
// machines is not healthy.
KubeadmControlPlaneEtcdClusterNotHealthyV1Beta2Reason = "NotHealthy"
sbueringer marked this conversation as resolved.
Show resolved Hide resolved

// KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason surfaces when the health status of the etcd cluster hosted
// on KubeadmControlPlane machines is unknown.
KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason = "HealthUnknown"
)

// KubeadmControlPlane's ControlPlaneComponentsHealthy condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition surfaces issues to Kubernetes control plane components
// hosted on machines managed by this object. It is computed as aggregation of Machine's `APIServerPodHealthy`,
// `ControllerManagerPodHealthy`, `SchedulerPodHealthy`, `EtcdPodHealthy` conditions plus additional checks on
// control plane machines and nodes.
KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition = "ControlPlaneComponentsHealthy"

// KubeadmControlPlaneControlPlaneComponentsInspectionFailedV1Beta2Reason documents a failure when inspecting the status of the
// control plane components hosted on KubeadmControlPlane controlled machines.
KubeadmControlPlaneControlPlaneComponentsInspectionFailedV1Beta2Reason = clusterv1.InspectionFailedV1Beta2Reason

// KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Reason surfaces when the Kubernetes control plane components
// hosted on KubeadmControlPlane machines are healthy.
KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Reason = "Healthy"

// KubeadmControlPlaneControlPlaneComponentsNotHealthyV1Beta2Reason surfaces when the Kubernetes control plane components
// hosted on KubeadmControlPlane machines are not healthy.
KubeadmControlPlaneControlPlaneComponentsNotHealthyV1Beta2Reason = "NotHealthy"

// KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason surfaces when the health status of the
// Kubernetes control plane components hosted on KubeadmControlPlane machines is unknown.
KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason = "HealthUnknown"
)

// KubeadmControlPlane's MachinesReady condition and corresponding reasons that will be used in v1Beta2 API version.
Expand Down Expand Up @@ -113,7 +155,8 @@ const (
KubeadmControlPlanePausedV1Beta2Condition = clusterv1.PausedV1Beta2Condition
)

// Conditions that will be used for the KubeadmControlPlane controlled machines in v1Beta2 API version.
// APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy and EtcdPodHealthy condition and corresponding
// reasons that will be used for KubeadmControlPlane controlled machines in v1Beta2 API version.
const (
// KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition surfaces the status of the API server pod hosted on a KubeadmControlPlane controlled machine.
KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition = "APIServerPodHealthy"
Expand All @@ -127,6 +170,50 @@ const (
// KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition surfaces the status of the etcd pod hosted on a KubeadmControlPlane controlled machine.
KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition = "EtcdPodHealthy"

// KubeadmControlPlaneMachinePodRunningV1Beta2Reason surfaces a pod hosted on a KubeadmControlPlane controlled machine that is running.
KubeadmControlPlaneMachinePodRunningV1Beta2Reason = "Running"

// KubeadmControlPlaneMachinePodProvisioningV1Beta2Reason surfaces a pod hosted on a KubeadmControlPlane controlled machine
// waiting to be provisioned i.e., Pod is in "Pending" phase.
KubeadmControlPlaneMachinePodProvisioningV1Beta2Reason = "Provisioning"

// KubeadmControlPlaneMachinePodDoesNotExistV1Beta2Reason surfaces a when a pod hosted on a KubeadmControlPlane controlled machine
// does not exist.
KubeadmControlPlaneMachinePodDoesNotExistV1Beta2Reason = "DoesNotExist"

// KubeadmControlPlaneMachinePodFailedV1Beta2Reason surfaces a when a pod hosted on a KubeadmControlPlane controlled machine
// failed during provisioning, e.g. CrashLoopBackOff, ImagePullBackOff or if all the containers in a pod have terminated.
KubeadmControlPlaneMachinePodFailedV1Beta2Reason = "Failed"

// KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason documents a failure when inspecting the status of a
// pod hosted on a KubeadmControlPlane controlled machine.
KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason = clusterv1.InspectionFailedV1Beta2Reason

// KubeadmControlPlaneMachinePodDeletingV1Beta2Reason surfaces when the machine hosting control plane components
// is being deleted.
KubeadmControlPlaneMachinePodDeletingV1Beta2Reason = "Deleting"

// KubeadmControlPlaneMachinePodInternalErrorV1Beta2Reason surfaces unexpected failures when reading pod hosted
// on a KubeadmControlPlane controlled machine.
KubeadmControlPlaneMachinePodInternalErrorV1Beta2Reason = clusterv1.InternalErrorV1Beta2Reason
)

// EtcdMemberHealthy condition and corresponding reasons that will be used for KubeadmControlPlane controlled machines in v1Beta2 API version.
const (
// KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition surfaces the status of the etcd member hosted on a KubeadmControlPlane controlled machine.
KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition = "EtcdMemberHealthy"
KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition = "Healthy"

// KubeadmControlPlaneMachineEtcdMemberNotHealthyV1Beta2Reason surfaces when the etcd member hosted on a KubeadmControlPlane controlled machine is not healthy.
KubeadmControlPlaneMachineEtcdMemberNotHealthyV1Beta2Reason = "NotHealthy"

// KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Reason surfaces when the etcd member hosted on a KubeadmControlPlane controlled machine is healthy.
KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Reason = "Healthy"

// KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason documents a failure when inspecting the status of an
// etcd member hosted on a KubeadmControlPlane controlled machine.
KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason = clusterv1.InspectionFailedV1Beta2Reason

// KubeadmControlPlaneMachineEtcdMemberDeletingV1Beta2Reason surfaces when the machine hosting an etcd member
// is being deleted.
KubeadmControlPlaneMachineEtcdMemberDeletingV1Beta2Reason = "Deleting"
)
32 changes: 23 additions & 9 deletions controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,29 @@ func patchKubeadmControlPlane(ctx context.Context, patchHelper *patch.Helper, kc
// Patch the object, ignoring conflicts on the conditions owned by this controller.
// Also, if requested, we are adding additional options like e.g. Patch ObservedGeneration when issuing the
// patch at the end of the reconcile loop.
options = append(options, patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
controlplanev1.MachinesCreatedCondition,
clusterv1.ReadyCondition,
controlplanev1.MachinesSpecUpToDateCondition,
controlplanev1.ResizedCondition,
controlplanev1.MachinesReadyCondition,
controlplanev1.AvailableCondition,
controlplanev1.CertificatesAvailableCondition,
}})
options = append(options,
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
controlplanev1.MachinesCreatedCondition,
clusterv1.ReadyCondition,
controlplanev1.MachinesSpecUpToDateCondition,
controlplanev1.ResizedCondition,
controlplanev1.MachinesReadyCondition,
controlplanev1.AvailableCondition,
controlplanev1.CertificatesAvailableCondition,
}},
patch.WithOwnedV1Beta2Conditions{Conditions: []string{
controlplanev1.KubeadmControlPlaneAvailableV1Beta2Condition,
controlplanev1.KubeadmControlPlaneCertificatesAvailableV1Beta2Condition,
controlplanev1.KubeadmControlPlaneEtcdClusterHealthyV1Beta2Condition,
controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
controlplanev1.KubeadmControlPlaneMachinesReadyV1Beta2Condition,
controlplanev1.KubeadmControlPlaneMachinesUpToDateV1Beta2Condition,
controlplanev1.KubeadmControlPlaneScalingUpV1Beta2Condition,
controlplanev1.KubeadmControlPlaneScalingDownV1Beta2Condition,
controlplanev1.KubeadmControlPlaneRemediatingV1Beta2Condition,
controlplanev1.KubeadmControlPlaneDeletingV1Beta2Condition,
}},
)

return patchHelper.Patch(ctx, kcp, options...)
}
Expand Down
Loading