diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go index 896ef5d0e36c..5c8c0569a164 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go @@ -113,6 +113,8 @@ const ( initConfiguration = "initConfiguration" joinConfiguration = "joinConfiguration" nodeRegistration = "nodeRegistration" + patches = "patches" + directory = "directory" preKubeadmCommands = "preKubeadmCommands" postKubeadmCommands = "postKubeadmCommands" files = "files" @@ -140,7 +142,9 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error { {spec, kubeadmConfigSpec, clusterConfiguration, controllerManager, "*"}, {spec, kubeadmConfigSpec, clusterConfiguration, scheduler, "*"}, {spec, kubeadmConfigSpec, initConfiguration, nodeRegistration, "*"}, + {spec, kubeadmConfigSpec, initConfiguration, patches, directory}, {spec, kubeadmConfigSpec, joinConfiguration, nodeRegistration, "*"}, + {spec, kubeadmConfigSpec, joinConfiguration, patches, directory}, {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 9923c95274b9..14aaa6dae1bd 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go @@ -594,6 +594,16 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { validIgnitionConfigurationAfter := validIgnitionConfigurationBefore.DeepCopy() validIgnitionConfigurationAfter.Spec.KubeadmConfigSpec.Ignition.ContainerLinuxConfig.AdditionalConfig = "foo: bar" + updateInitConfigurationPatches := before.DeepCopy() + updateInitConfigurationPatches.Spec.KubeadmConfigSpec.InitConfiguration.Patches = &bootstrapv1.Patches{ + Directory: "/tmp/patches", + } + + updateJoinConfigurationPatches := before.DeepCopy() + updateJoinConfigurationPatches.Spec.KubeadmConfigSpec.InitConfiguration.Patches = &bootstrapv1.Patches{ + Directory: "/tmp/patches", + } + tests := []struct { name string enableIgnitionFeature bool @@ -900,6 +910,18 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { before: before, kcp: disableNTPServers, }, + { + name: "should allow changes to initConfiguration.patches", + expectErr: false, + before: before, + kcp: updateInitConfigurationPatches, + }, + { + name: "should allow changes to joinConfiguration.patches", + expectErr: false, + before: before, + kcp: updateJoinConfigurationPatches, + }, { name: "should return error when Ignition configuration is invalid", enableIgnitionFeature: true,