From 650b1879a586228d9ec5d81f3dd86016f588aa5d Mon Sep 17 00:00:00 2001 From: Jim Ntosas Date: Mon, 28 Nov 2022 14:52:09 +0200 Subject: [PATCH] [kcp] Make kcp.skipPhases field mutable Makes KCP skipPhases field mutable, needed in cases like disabling kube-proxy deployment on an existing cluster. Signed-off-by: Jim Ntosas --- .../v1beta1/kubeadm_control_plane_webhook.go | 3 +++ .../kubeadm_control_plane_webhook_test.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go index 285cbeca3099..e8f4a68367cb 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go @@ -115,6 +115,7 @@ const ( initConfiguration = "initConfiguration" joinConfiguration = "joinConfiguration" nodeRegistration = "nodeRegistration" + skipPhases = "skipPhases" patches = "patches" directory = "directory" preKubeadmCommands = "preKubeadmCommands" @@ -148,8 +149,10 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error { {spec, kubeadmConfigSpec, clusterConfiguration, scheduler, "*"}, {spec, kubeadmConfigSpec, initConfiguration, nodeRegistration, "*"}, {spec, kubeadmConfigSpec, initConfiguration, patches, directory}, + {spec, kubeadmConfigSpec, initConfiguration, skipPhases}, {spec, kubeadmConfigSpec, joinConfiguration, nodeRegistration, "*"}, {spec, kubeadmConfigSpec, joinConfiguration, patches, directory}, + {spec, kubeadmConfigSpec, joinConfiguration, skipPhases}, {spec, kubeadmConfigSpec, preKubeadmCommands}, {spec, kubeadmConfigSpec, postKubeadmCommands}, {spec, kubeadmConfigSpec, files}, diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go index d8c52f7ce7d2..f13d34b36cb9 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go @@ -651,6 +651,12 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { Directory: "/tmp/patches", } + updateInitConfigurationSkipPhases := before.DeepCopy() + updateInitConfigurationSkipPhases.Spec.KubeadmConfigSpec.InitConfiguration.SkipPhases = []string{"addon/kube-proxy"} + + updateJoinConfigurationSkipPhases := before.DeepCopy() + updateJoinConfigurationSkipPhases.Spec.KubeadmConfigSpec.JoinConfiguration.SkipPhases = []string{"addon/kube-proxy"} + updateDiskSetup := before.DeepCopy() updateDiskSetup.Spec.KubeadmConfigSpec.DiskSetup = &bootstrapv1.DiskSetup{ Filesystems: []bootstrapv1.Filesystem{ @@ -985,6 +991,18 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { before: before, kcp: updateJoinConfigurationPatches, }, + { + name: "should allow changes to initConfiguration.skipPhases", + expectErr: false, + before: before, + kcp: updateInitConfigurationSkipPhases, + }, + { + name: "should allow changes to joinConfiguration.skipPhases", + expectErr: false, + before: before, + kcp: updateJoinConfigurationSkipPhases, + }, { name: "should allow changes to diskSetup", expectErr: false,