diff --git a/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook.go b/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook.go index 066626252b71..05813fc926a3 100644 --- a/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook.go +++ b/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook.go @@ -230,6 +230,10 @@ func (in *KubeadmControlPlane) validateCommon() (allErrs field.ErrorList) { } func (in *KubeadmControlPlane) validateEtcd(prev *KubeadmControlPlane) (allErrs field.ErrorList) { + if in.Spec.KubeadmConfigSpec.ClusterConfiguration == nil { + return allErrs + } + if in.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.External != nil && prev.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local != nil { allErrs = append( allErrs, diff --git a/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook_test.go b/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook_test.go index dfa3e05b762e..d3347aebab7c 100644 --- a/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook_test.go +++ b/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_webhook_test.go @@ -296,6 +296,9 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { }, } + withoutClusterConfiguration := before.DeepCopy() + withoutClusterConfiguration.Spec.KubeadmConfigSpec.ClusterConfiguration = nil + tests := []struct { name string expectErr bool @@ -476,6 +479,12 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { before: beforeInvalidEtcdCluster, kcp: afterInvalidEtcdCluster, }, + { + name: "should pass if ClusterConfiguration is nil", + expectErr: false, + before: withoutClusterConfiguration, + kcp: withoutClusterConfiguration, + }, } for _, tt := range tests {