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

Patch legacy annotation on pre 0.3 RKE2 control planes #469

Merged
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
4 changes: 4 additions & 0 deletions controlplane/api/v1alpha1/rke2controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const (
// RKE2ServerConfigurationAnnotation is a machine annotation that stores the json-marshalled string of RKE2Config
// This annotation is used to detect any changes in RKE2Config and trigger machine rollout.
RKE2ServerConfigurationAnnotation = "controlplane.cluster.x-k8s.io/rke2-server-configuration"

// LegacyRKE2ControlPlane is a controlplane annotation that marks the CP as legacy. This CP will not provide
// etcd certificate management or etcd membership management.
LegacyRKE2ControlPlane = "controlplane.cluster.x-k8s.io/legacy"
)

// RKE2ControlPlaneSpec defines the desired state of RKE2ControlPlane.
Expand Down
12 changes: 12 additions & 0 deletions controlplane/internal/controllers/rke2controlplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ func (r *RKE2ControlPlaneReconciler) reconcileNormal(
logger := log.FromContext(ctx)
logger.Info("Reconcile RKE2 Control Plane")

if rcp.Annotations == nil {
rcp.Annotations = map[string]string{}
}

rcp.Annotations[controlplanev1.LegacyRKE2ControlPlane] = ""

// Wait for the cluster infrastructure to be ready before creating machines
if !cluster.Status.InfrastructureReady {
logger.Info("Cluster infrastructure is not ready yet")
Expand Down Expand Up @@ -527,6 +533,12 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
) (res ctrl.Result, err error) {
logger := log.FromContext(ctx)

if rcp.Annotations == nil {
rcp.Annotations = map[string]string{}
}

rcp.Annotations[controlplanev1.LegacyRKE2ControlPlane] = ""

// Gets all machines, not just control plane machines.
allMachines, err := r.managementCluster.GetMachinesForCluster(ctx, util.ObjectKey(cluster))
if err != nil {
Expand Down
Loading