-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CAPI patch to support in-place upgrade in KCP (#2822)
- Loading branch information
1 parent
bcfa291
commit 7e2b9de
Showing
2 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
8a009d153d56a6d81e06428711aeecc217d9f4707471851d9fcff0820b601c47 _output/bin/cluster-api/linux-amd64/cluster-api-provider-docker-manager | ||
853efbf32c9a44edcf4816e24a5ba18c3b4c291b3c13546e9c2a028b19f472ad _output/bin/cluster-api/linux-amd64/clusterctl | ||
07189d12d166319ae0aa36a279e2bc6af913a6ceca2621c019fc83cdb3bd271c _output/bin/cluster-api/linux-amd64/kubeadm-bootstrap-manager | ||
3d5f6f72d4b7c74c0097f2854066cc55b7be31841a1cad35fa6738883aa16b68 _output/bin/cluster-api/linux-amd64/kubeadm-control-plane-manager | ||
c16ae332488a063969e17d03e404d7add1b5e00d67119a06e97f483a3f0d4bb0 _output/bin/cluster-api/linux-amd64/manager | ||
254b2fa5972428e3eac45b76f75523019ae289f2307af18a3903bf4480ee078a _output/bin/cluster-api/linux-arm64/cluster-api-provider-docker-manager | ||
68f0ca12b8cd80cdc52995236770530ad70491004f64e1a3ad67abe8cf592e3c _output/bin/cluster-api/linux-arm64/clusterctl | ||
2816ba9ad224d286d1aaf877d3dc3cd66d41c9c35f7c16aca0d8b66c723c5b16 _output/bin/cluster-api/linux-arm64/kubeadm-bootstrap-manager | ||
cf72aae2400e25f2bbe60ebc058bbc308e7a00837048fa10df18dfb1c9f888c3 _output/bin/cluster-api/linux-arm64/kubeadm-control-plane-manager | ||
3565095fe0d684d6289bc53688928500ada8cf014bc4a4742e8bc6ba8ff8c0b7 _output/bin/cluster-api/linux-arm64/manager | ||
8d75c41829c86e1340443eb4c48a604b2dc680530300a20dda3e2b3c290c9047 _output/bin/cluster-api/linux-amd64/cluster-api-provider-docker-manager | ||
0a5b6099f80f82ef0d4dfae0ce2dcffe96819163373cf2ff41c598672357139f _output/bin/cluster-api/linux-amd64/clusterctl | ||
e263f8ac74622367487a1e49f3822caea21b814d5f321cae4d4ac8089dc0189f _output/bin/cluster-api/linux-amd64/kubeadm-bootstrap-manager | ||
8c2acaafc4d212202a1cca6ff2c5b0985f1db0e2729e00c6bf0da6aabc14590d _output/bin/cluster-api/linux-amd64/kubeadm-control-plane-manager | ||
bf65de26330f9b7df377f824eedece8a156c034fd90a378b38c961547a9cdb38 _output/bin/cluster-api/linux-amd64/manager | ||
5bae0734b01e5b614028c9552df20ac95547f669475ae7995240f497def1c377 _output/bin/cluster-api/linux-arm64/cluster-api-provider-docker-manager | ||
2c11737adb858e53159798aeb7090a0abc9e1e056fbc587d2fe58bebc3799932 _output/bin/cluster-api/linux-arm64/clusterctl | ||
47af4e933fa23d90a6510d76fff9d6aa25c9799ac6a4f96882832058da33b77e _output/bin/cluster-api/linux-arm64/kubeadm-bootstrap-manager | ||
40a8e36f663ef3a25261513442fe3e9acd9c35bc62258292d20fad7bd8cc6ddc _output/bin/cluster-api/linux-arm64/kubeadm-control-plane-manager | ||
3b0d7261b88b3c0e0110738fb14f896d414b42dc4f86612f60426d42fb1ddea9 _output/bin/cluster-api/linux-arm64/manager |
105 changes: 105 additions & 0 deletions
105
...ts/kubernetes-sigs/cluster-api/patches/0037-Add-support-for-in-place-upgrade-in-KCP.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
From 039bc59ba1368f4dce9ce7840ff54d5fd9d398a0 Mon Sep 17 00:00:00 2001 | ||
From: Abhinav Pandey <abhinavmpandey08@gmail.com> | ||
Date: Wed, 17 Jan 2024 09:28:18 -0800 | ||
Subject: [PATCH] Add support for in-place upgrade in KCP | ||
|
||
--- | ||
.../kubeadm/api/v1beta1/kubeadm_control_plane_types.go | 8 ++++++++ | ||
controlplane/kubeadm/internal/controllers/upgrade.go | 10 ++++++++-- | ||
.../kubeadm/internal/webhooks/kubeadm_control_plane.go | 4 ++-- | ||
3 files changed, 18 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go | ||
index 8e488f187..32b297f12 100644 | ||
--- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go | ||
+++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go | ||
@@ -35,6 +35,9 @@ const ( | ||
// RollingUpdateStrategyType replaces the old control planes by new one using rolling update | ||
// i.e. gradually scale up or down the old control planes and scale up or down the new one. | ||
RollingUpdateStrategyType RolloutStrategyType = "RollingUpdate" | ||
+ | ||
+ // InPlaceUpgradeStrategyType updates the node in place by delegating the upgrade to an external entity. | ||
+ InPlaceUpgradeStrategyType RolloutStrategyType = "InPlace" | ||
) | ||
|
||
const ( | ||
@@ -65,6 +68,11 @@ const ( | ||
// failures in updating remediation retry (the counter restarts from zero). | ||
RemediationForAnnotation = "controlplane.cluster.x-k8s.io/remediation-for" | ||
|
||
+ // InPlaceUpgradeAnnotation is used to denote that the KCP object needs to be in-place upgraded by an external entity. | ||
+ // This annotation will be added to the KCP object when `rolloutStrategy.type` is set to `InPlace`. | ||
+ // The external upgrader entity should watch for the annotation and trigger an upgrade when it's added. | ||
+ InPlaceUpgradeAnnotation = "controlplane.clusters.x-k8s.io/in-place-upgrade-needed" | ||
+ | ||
// DefaultMinHealthyPeriod defines the default minimum period before we consider a remediation on a | ||
// machine unrelated from the previous remediation. | ||
DefaultMinHealthyPeriod = 1 * time.Hour | ||
diff --git a/controlplane/kubeadm/internal/controllers/upgrade.go b/controlplane/kubeadm/internal/controllers/upgrade.go | ||
index 647d87f6a..e436eb546 100644 | ||
--- a/controlplane/kubeadm/internal/controllers/upgrade.go | ||
+++ b/controlplane/kubeadm/internal/controllers/upgrade.go | ||
@@ -18,6 +18,7 @@ package controllers | ||
|
||
import ( | ||
"context" | ||
+ "time" | ||
|
||
"github.com/blang/semver/v4" | ||
"github.com/pkg/errors" | ||
@@ -26,6 +27,7 @@ import ( | ||
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" | ||
"sigs.k8s.io/cluster-api/controlplane/kubeadm/internal" | ||
"sigs.k8s.io/cluster-api/util" | ||
+ "sigs.k8s.io/cluster-api/util/annotations" | ||
"sigs.k8s.io/cluster-api/util/collections" | ||
"sigs.k8s.io/cluster-api/util/version" | ||
) | ||
@@ -37,7 +39,7 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane( | ||
) (ctrl.Result, error) { | ||
logger := ctrl.LoggerFrom(ctx) | ||
|
||
- if controlPlane.KCP.Spec.RolloutStrategy == nil || controlPlane.KCP.Spec.RolloutStrategy.RollingUpdate == nil { | ||
+ if controlPlane.KCP.Spec.RolloutStrategy == nil { | ||
return ctrl.Result{}, errors.New("rolloutStrategy is not set") | ||
} | ||
|
||
@@ -138,8 +140,12 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane( | ||
return r.scaleUpControlPlane(ctx, controlPlane) | ||
} | ||
return r.scaleDownControlPlane(ctx, controlPlane, machinesRequireUpgrade) | ||
+ case controlplanev1.InPlaceUpgradeStrategyType: | ||
+ annotations.AddAnnotations(controlPlane.KCP, map[string]string{controlplanev1.InPlaceUpgradeAnnotation: "true"}) | ||
+ logger.Info("RolloutStrategy type set to InPlaceUpgradeStrategyType, adding the annotation and requeuing", "annotation", controlplanev1.InPlaceUpgradeAnnotation) | ||
+ return ctrl.Result{RequeueAfter: time.Second * 30}, nil | ||
default: | ||
- logger.Info("RolloutStrategy type is not set to RollingUpdateStrategyType, unable to determine the strategy for rolling out machines") | ||
+ logger.Info("RolloutStrategy type is not set to RollingUpdateStrategyType or InPlaceUpgradeStrategyType, unable to determine the strategy for rolling out machines") | ||
return ctrl.Result{}, nil | ||
} | ||
} | ||
diff --git a/controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go b/controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go | ||
index f39201995..1d0631456 100644 | ||
--- a/controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go | ||
+++ b/controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go | ||
@@ -407,7 +407,7 @@ func validateRolloutBefore(rolloutBefore *controlplanev1.RolloutBefore, pathPref | ||
func validateRolloutStrategy(rolloutStrategy *controlplanev1.RolloutStrategy, replicas *int32, pathPrefix *field.Path) field.ErrorList { | ||
allErrs := field.ErrorList{} | ||
|
||
- if rolloutStrategy == nil { | ||
+ if rolloutStrategy == nil || rolloutStrategy.Type == controlplanev1.InPlaceUpgradeStrategyType { | ||
return allErrs | ||
} | ||
|
||
@@ -416,7 +416,7 @@ func validateRolloutStrategy(rolloutStrategy *controlplanev1.RolloutStrategy, re | ||
allErrs, | ||
field.Required( | ||
pathPrefix.Child("type"), | ||
- "only RollingUpdateStrategyType is supported", | ||
+ "only RollingUpdateStrategyType and InPlaceUpgradeStrategyType are supported", | ||
), | ||
) | ||
} | ||
-- | ||
2.42.0 | ||
|