diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go index 8ace322bbdf0..896ef5d0e36c 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go @@ -500,7 +500,11 @@ func (in *KubeadmControlPlane) validateCoreDNSVersion(prev *KubeadmControlPlane) ) return allErrs } - + // If the versions are equal return here without error. + // This allows an upgrade where the version of CoreDNS in use is not supported by the migration tool. + if toVersion.Equals(fromVersion) { + return allErrs + } if err := migration.ValidUpMigration(fromVersion.String(), toVersion.String()); err != nil { allErrs = append( allErrs, 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 cb86359df9ab..9923c95274b9 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go @@ -484,6 +484,13 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { ImageTag: "v1.6.6_foobar.2", }, } + validUnsupportedCoreDNSVersion := dns.DeepCopy() + validUnsupportedCoreDNSVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{ + ImageMeta: bootstrapv1.ImageMeta{ + ImageRepository: "gcr.io/capi-test", + ImageTag: "v99.99.99", + }, + } unsetCoreDNSToVersion := dns.DeepCopy() unsetCoreDNSToVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{ @@ -744,6 +751,16 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { before: before, kcp: dnsBuildTag, }, + { + name: "should succeed when using the same CoreDNS version", + before: dns, + kcp: dns.DeepCopy(), + }, + { + name: "should succeed when using the same CoreDNS version - not supported", + before: validUnsupportedCoreDNSVersion, + kcp: validUnsupportedCoreDNSVersion, + }, { name: "should fail when using an invalid DNS build", expectErr: true, @@ -756,6 +773,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) { before: dns, kcp: dnsInvalidCoreDNSToVersion, }, + { name: "should fail when making a change to the cluster config's certificatesDir", expectErr: true,