From ca725f211cd276f4924e60bcffebd3e6bd5d3fc1 Mon Sep 17 00:00:00 2001 From: Ludovico Russo Date: Thu, 22 Apr 2021 22:08:27 +0200 Subject: [PATCH] remove DNS type from api v1alpha4 --- .../kubeadm/api/v1alpha3/conversion_test.go | 16 +++- .../api/v1alpha3/zz_generated.conversion.go | 95 ++++++++++++++++++- .../kubeadm/api/v1alpha4/kubeadm_types.go | 4 - ...strap.cluster.x-k8s.io_kubeadmconfigs.yaml | 3 - ...uster.x-k8s.io_kubeadmconfigtemplates.yaml | 3 - .../kubeadm/types/v1beta1/conversion_test.go | 20 ++++ .../types/v1beta1/zz_generated.conversion.go | 13 ++- .../kubeadm/types/v1beta2/conversion_test.go | 8 ++ .../types/v1beta2/zz_generated.conversion.go | 12 +-- .../kubeadm/api/v1alpha3/conversion_test.go | 5 + .../v1alpha4/kubeadm_control_plane_webhook.go | 5 - ...cluster.x-k8s.io_kubeadmcontrolplanes.yaml | 3 - .../kubeadm/controllers/controller_test.go | 1 - .../internal/workload_cluster_coredns.go | 4 - .../internal/workload_cluster_coredns_test.go | 31 +----- 15 files changed, 149 insertions(+), 74 deletions(-) diff --git a/bootstrap/kubeadm/api/v1alpha3/conversion_test.go b/bootstrap/kubeadm/api/v1alpha3/conversion_test.go index 88a6228317ec..7b68364b6341 100644 --- a/bootstrap/kubeadm/api/v1alpha3/conversion_test.go +++ b/bootstrap/kubeadm/api/v1alpha3/conversion_test.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" + "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/v1beta1" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -42,15 +43,17 @@ func TestFuzzyConversion(t *testing.T) { FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigStatusFuzzFuncs}, })) t.Run("for KubeadmConfigTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Scheme: scheme, - Hub: &v1alpha4.KubeadmConfigTemplate{}, - Spoke: &KubeadmConfigTemplate{}, + Scheme: scheme, + Hub: &v1alpha4.KubeadmConfigTemplate{}, + Spoke: &KubeadmConfigTemplate{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigStatusFuzzFuncs}, })) } func KubeadmConfigStatusFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ KubeadmConfigStatusFuzzer, + joinDNSFuzzer, } } @@ -60,3 +63,10 @@ func KubeadmConfigStatusFuzzer(obj *KubeadmConfigStatus, c fuzz.Continue) { // KubeadmConfigStatus.BootstrapData has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors. obj.BootstrapData = nil } + +func joinDNSFuzzer(obj *v1beta1.DNS, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // DNS.Type does not exists in v1alpha4, so setting it to empty string in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors. + obj.Type = "CoreDNS" +} diff --git a/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go b/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go index c00d5b019d1f..f1e00961e4d4 100644 --- a/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go +++ b/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go @@ -383,8 +383,41 @@ func Convert_v1alpha4_KubeadmConfigList_To_v1alpha3_KubeadmConfigList(in *v1alph return autoConvert_v1alpha4_KubeadmConfigList_To_v1alpha3_KubeadmConfigList(in, out, s) } +func convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in *v1beta1.ClusterConfiguration) (*v1alpha4.ClusterConfiguration, error) { + if in == nil { + return nil, nil + } + out := new(v1alpha4.ClusterConfiguration) + out.DNS = v1alpha4.DNS{ + ImageMeta: v1alpha4.ImageMeta{ + ImageRepository: in.DNS.ImageRepository, + ImageTag: in.DNS.ImageTag, + }, + } + out.APIServer = *(*v1alpha4.APIServer)(unsafe.Pointer(&in.APIServer)) + out.APIVersion = in.APIVersion + out.CertificatesDir = in.CertificatesDir + out.ClusterName = in.ClusterName + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + out.ControllerManager = *(*v1alpha4.ControlPlaneComponent)(unsafe.Pointer(&in.ControllerManager)) + out.Etcd = *(*v1alpha4.Etcd)(unsafe.Pointer(&in.Etcd)) + out.FeatureGates = in.FeatureGates + out.ImageRepository = in.ImageRepository + out.Kind = in.Kind + out.KubernetesVersion = in.KubernetesVersion + out.Networking = *(*v1alpha4.Networking)(unsafe.Pointer(&in.Networking)) + out.Scheduler = *(*v1alpha4.ControlPlaneComponent)(unsafe.Pointer(&in.Scheduler)) + out.TypeMeta = in.TypeMeta + out.UseHyperKubeImage = in.UseHyperKubeImage + return out, nil +} + func autoConvert_v1alpha3_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *KubeadmConfigSpec, out *v1alpha4.KubeadmConfigSpec, s conversion.Scope) error { - out.ClusterConfiguration = (*v1alpha4.ClusterConfiguration)(unsafe.Pointer(in.ClusterConfiguration)) + outClusterConfig, err := convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in.ClusterConfiguration) + if err != nil { + return err + } + out.ClusterConfiguration = outClusterConfig out.InitConfiguration = (*v1alpha4.InitConfiguration)(unsafe.Pointer(in.InitConfiguration)) out.JoinConfiguration = (*v1alpha4.JoinConfiguration)(unsafe.Pointer(in.JoinConfiguration)) out.Files = *(*[]v1alpha4.File)(unsafe.Pointer(&in.Files)) @@ -405,8 +438,42 @@ func Convert_v1alpha3_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *Kubead return autoConvert_v1alpha3_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in, out, s) } +func convert_v1alpha4_ClusterConfiguration_To_v1beta1_ClusterConfiguration(in *v1alpha4.ClusterConfiguration) (*v1beta1.ClusterConfiguration, error) { + if in == nil { + return nil, nil + } + out := new(v1beta1.ClusterConfiguration) + out.DNS = v1beta1.DNS{ + Type: v1beta1.CoreDNS, + ImageMeta: v1beta1.ImageMeta{ + ImageRepository: in.DNS.ImageRepository, + ImageTag: in.DNS.ImageTag, + }, + } + out.APIServer = *(*v1beta1.APIServer)(unsafe.Pointer(&in.APIServer)) + out.APIVersion = in.APIVersion + out.CertificatesDir = in.CertificatesDir + out.ClusterName = in.ClusterName + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + out.ControllerManager = *(*v1beta1.ControlPlaneComponent)(unsafe.Pointer(&in.ControllerManager)) + out.Etcd = *(*v1beta1.Etcd)(unsafe.Pointer(&in.Etcd)) + out.FeatureGates = in.FeatureGates + out.ImageRepository = in.ImageRepository + out.Kind = in.Kind + out.KubernetesVersion = in.KubernetesVersion + out.Networking = *(*v1beta1.Networking)(unsafe.Pointer(&in.Networking)) + out.Scheduler = *(*v1beta1.ControlPlaneComponent)(unsafe.Pointer(&in.Scheduler)) + out.TypeMeta = in.TypeMeta + out.UseHyperKubeImage = in.UseHyperKubeImage + return out, nil +} + func autoConvert_v1alpha4_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *v1alpha4.KubeadmConfigSpec, out *KubeadmConfigSpec, s conversion.Scope) error { - out.ClusterConfiguration = (*v1beta1.ClusterConfiguration)(unsafe.Pointer(in.ClusterConfiguration)) + outClusterConfig, err := convert_v1alpha4_ClusterConfiguration_To_v1beta1_ClusterConfiguration(in.ClusterConfiguration) + if err != nil { + return err + } + out.ClusterConfiguration = outClusterConfig out.InitConfiguration = (*v1beta1.InitConfiguration)(unsafe.Pointer(in.InitConfiguration)) out.JoinConfiguration = (*v1beta1.JoinConfiguration)(unsafe.Pointer(in.JoinConfiguration)) out.Files = *(*[]File)(unsafe.Pointer(&in.Files)) @@ -501,7 +568,17 @@ func Convert_v1alpha4_KubeadmConfigTemplate_To_v1alpha3_KubeadmConfigTemplate(in func autoConvert_v1alpha3_KubeadmConfigTemplateList_To_v1alpha4_KubeadmConfigTemplateList(in *KubeadmConfigTemplateList, out *v1alpha4.KubeadmConfigTemplateList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1alpha4.KubeadmConfigTemplate)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1alpha4.KubeadmConfigTemplate, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_KubeadmConfigTemplate_To_v1alpha4_KubeadmConfigTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -512,7 +589,17 @@ func Convert_v1alpha3_KubeadmConfigTemplateList_To_v1alpha4_KubeadmConfigTemplat func autoConvert_v1alpha4_KubeadmConfigTemplateList_To_v1alpha3_KubeadmConfigTemplateList(in *v1alpha4.KubeadmConfigTemplateList, out *KubeadmConfigTemplateList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]KubeadmConfigTemplate)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KubeadmConfigTemplate, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_KubeadmConfigTemplate_To_v1alpha3_KubeadmConfigTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } diff --git a/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go b/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go index 899bde258496..3a9633465812 100644 --- a/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go +++ b/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go @@ -167,10 +167,6 @@ const ( // DNS defines the DNS addon that should be used in the cluster. type DNS struct { - // Type defines the DNS add-on to be used - // +optional - Type DNSAddOnType `json:"type,omitempty"` - // ImageMeta allows to customize the image used for the DNS component ImageMeta `json:",inline"` } diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml index ae0013385cf9..950b34ef8a51 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml @@ -834,9 +834,6 @@ spec: imageTag: description: ImageTag allows to specify a tag for the image. In case this value is set, kubeadm does not change automatically the version of the above components during upgrades. type: string - type: - description: Type defines the DNS add-on to be used - type: string type: object etcd: description: 'Etcd holds configuration for etcd. NB: This value defaults to a Local (stacked) etcd' diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml index c32227c336ea..19a7dacff603 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml @@ -795,9 +795,6 @@ spec: imageTag: description: ImageTag allows to specify a tag for the image. In case this value is set, kubeadm does not change automatically the version of the above components during upgrades. type: string - type: - description: Type defines the DNS add-on to be used - type: string type: object etcd: description: 'Etcd holds configuration for etcd. NB: This value defaults to a Local (stacked) etcd' diff --git a/bootstrap/kubeadm/types/v1beta1/conversion_test.go b/bootstrap/kubeadm/types/v1beta1/conversion_test.go index e46208352b9a..54097401aeec 100644 --- a/bootstrap/kubeadm/types/v1beta1/conversion_test.go +++ b/bootstrap/kubeadm/types/v1beta1/conversion_test.go @@ -19,8 +19,11 @@ package v1beta1 import ( "testing" + fuzz "github.com/google/gofuzz" . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/runtime" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -37,6 +40,7 @@ func TestFuzzyConversion(t *testing.T) { Spoke: &ClusterConfiguration{}, // NOTE: Kubeadm types does not have ObjectMeta, so we are required to skip data annotation cleanup in the spoke-hub-spoke round trip test. SkipSpokeAnnotationCleanup: true, + FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, })) t.Run("for ClusterStatus", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, @@ -44,6 +48,7 @@ func TestFuzzyConversion(t *testing.T) { Spoke: &ClusterStatus{}, // NOTE: Kubeadm types does not have ObjectMeta, so we are required to skip data annotation cleanup in the spoke-hub-spoke round trip test. SkipSpokeAnnotationCleanup: true, + FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, })) t.Run("for InitConfiguration", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, @@ -51,6 +56,7 @@ func TestFuzzyConversion(t *testing.T) { Spoke: &InitConfiguration{}, // NOTE: Kubeadm types does not have ObjectMeta, so we are required to skip data annotation cleanup in the spoke-hub-spoke round trip test. SkipSpokeAnnotationCleanup: true, + FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, })) t.Run("for JoinConfiguration", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, @@ -58,5 +64,19 @@ func TestFuzzyConversion(t *testing.T) { Spoke: &JoinConfiguration{}, // NOTE: Kubeadm types does not have ObjectMeta, so we are required to skip data annotation cleanup in the spoke-hub-spoke round trip test. SkipSpokeAnnotationCleanup: true, + FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, })) } + +func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + joinDNSFuzzer, + } +} + +func joinDNSFuzzer(obj *DNS, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // DNS.Type does not exists in v1alpha4, so setting it to empty string in order to avoid v1beta2 --> v1alpha4 --> v1beta2 round trip errors. + obj.Type = "" +} diff --git a/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go b/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go index 4c7a7644f198..56963326c203 100644 --- a/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go @@ -488,21 +488,20 @@ func Convert_v1alpha4_ControlPlaneComponent_To_v1beta1_ControlPlaneComponent(in return autoConvert_v1alpha4_ControlPlaneComponent_To_v1beta1_ControlPlaneComponent(in, out, s) } +// asd +func Convert_v1beta1_DNS_To_v1alpha4_DNS(in *DNS, out *v1alpha4.DNS, s conversion.Scope) error { + return autoConvert_v1beta1_DNS_To_v1alpha4_DNS(in, out, s) +} + func autoConvert_v1beta1_DNS_To_v1alpha4_DNS(in *DNS, out *v1alpha4.DNS, s conversion.Scope) error { - out.Type = v1alpha4.DNSAddOnType(in.Type) + // WARNING: in.Type requires manual conversion: does not exist in peer-type if err := Convert_v1beta1_ImageMeta_To_v1alpha4_ImageMeta(&in.ImageMeta, &out.ImageMeta, s); err != nil { return err } return nil } -// Convert_v1beta1_DNS_To_v1alpha4_DNS is an autogenerated conversion function. -func Convert_v1beta1_DNS_To_v1alpha4_DNS(in *DNS, out *v1alpha4.DNS, s conversion.Scope) error { - return autoConvert_v1beta1_DNS_To_v1alpha4_DNS(in, out, s) -} - func autoConvert_v1alpha4_DNS_To_v1beta1_DNS(in *v1alpha4.DNS, out *DNS, s conversion.Scope) error { - out.Type = DNSAddOnType(in.Type) if err := Convert_v1alpha4_ImageMeta_To_v1beta1_ImageMeta(&in.ImageMeta, &out.ImageMeta, s); err != nil { return err } diff --git a/bootstrap/kubeadm/types/v1beta2/conversion_test.go b/bootstrap/kubeadm/types/v1beta2/conversion_test.go index 785874b147bb..90bf2220a0b1 100644 --- a/bootstrap/kubeadm/types/v1beta2/conversion_test.go +++ b/bootstrap/kubeadm/types/v1beta2/conversion_test.go @@ -74,6 +74,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { nodeRegistrationOptionsFuzzer, initConfigurationFuzzer, joinControlPlanesFuzzer, + joinDNSFuzzer, } } @@ -97,3 +98,10 @@ func initConfigurationFuzzer(obj *InitConfiguration, c fuzz.Continue) { // InitConfiguration.CertificateKey does not exists in v1alpha4, so setting it to empty string in order to avoid v1beta2 --> v1alpha4 --> v1beta2 round trip errors. obj.CertificateKey = "" } + +func joinDNSFuzzer(obj *DNS, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // DNS.Type does not exists in v1alpha4, so setting it to empty string in order to avoid v1beta2 --> v1alpha4 --> v1beta2 round trip errors. + obj.Type = "" +} diff --git a/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go b/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go index d29a6d8e9513..49d0e12387ac 100644 --- a/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go @@ -488,21 +488,19 @@ func Convert_v1alpha4_ControlPlaneComponent_To_v1beta2_ControlPlaneComponent(in return autoConvert_v1alpha4_ControlPlaneComponent_To_v1beta2_ControlPlaneComponent(in, out, s) } +func Convert_v1beta2_DNS_To_v1alpha4_DNS(in *DNS, out *v1alpha4.DNS, s conversion.Scope) error { + return autoConvert_v1beta2_DNS_To_v1alpha4_DNS(in, out, s) +} + func autoConvert_v1beta2_DNS_To_v1alpha4_DNS(in *DNS, out *v1alpha4.DNS, s conversion.Scope) error { - out.Type = v1alpha4.DNSAddOnType(in.Type) + // WARNING: in.Type requires manual conversion: does not exist in peer-type if err := Convert_v1beta2_ImageMeta_To_v1alpha4_ImageMeta(&in.ImageMeta, &out.ImageMeta, s); err != nil { return err } return nil } -// Convert_v1beta2_DNS_To_v1alpha4_DNS is an autogenerated conversion function. -func Convert_v1beta2_DNS_To_v1alpha4_DNS(in *DNS, out *v1alpha4.DNS, s conversion.Scope) error { - return autoConvert_v1beta2_DNS_To_v1alpha4_DNS(in, out, s) -} - func autoConvert_v1alpha4_DNS_To_v1beta2_DNS(in *v1alpha4.DNS, out *DNS, s conversion.Scope) error { - out.Type = DNSAddOnType(in.Type) if err := Convert_v1alpha4_ImageMeta_To_v1beta2_ImageMeta(&in.ImageMeta, &out.ImageMeta, s); err != nil { return err } diff --git a/controlplane/kubeadm/api/v1alpha3/conversion_test.go b/controlplane/kubeadm/api/v1alpha3/conversion_test.go index 4795a54e6238..ea4a7f4f4da1 100644 --- a/controlplane/kubeadm/api/v1alpha3/conversion_test.go +++ b/controlplane/kubeadm/api/v1alpha3/conversion_test.go @@ -59,6 +59,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ kubeadmBootstrapTokenStringFuzzer, cabpkBootstrapTokenStringFuzzer, + kubeadmBookstrapDNSFuzzer, } } @@ -70,3 +71,7 @@ func cabpkBootstrapTokenStringFuzzer(in *cabpkv1.BootstrapTokenString, c fuzz.Co in.ID = "abcdef" in.Secret = "abcdef0123456789" } + +func kubeadmBookstrapDNSFuzzer(in *kubeadmv1beta1.DNS, c fuzz.Continue) { + in.Type = "kube-dns" +} diff --git a/controlplane/kubeadm/api/v1alpha4/kubeadm_control_plane_webhook.go b/controlplane/kubeadm/api/v1alpha4/kubeadm_control_plane_webhook.go index 9ef6ee5d9f63..3a93c68b2019 100644 --- a/controlplane/kubeadm/api/v1alpha4/kubeadm_control_plane_webhook.go +++ b/controlplane/kubeadm/api/v1alpha4/kubeadm_control_plane_webhook.go @@ -29,7 +29,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/validation/field" - bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" "sigs.k8s.io/cluster-api/util/container" "sigs.k8s.io/cluster-api/util/version" ctrl "sigs.k8s.io/controller-runtime" @@ -356,10 +355,6 @@ func (in *KubeadmControlPlane) validateCoreDNSVersion(prev *KubeadmControlPlane) return allErrs } targetDNS := &in.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS - //return if the type is anything other than empty (default), or CoreDNS. - if targetDNS.Type != "" && targetDNS.Type != bootstrapv1.CoreDNS { - return allErrs - } fromVersion, err := version.ParseMajorMinorPatchTolerant(prev.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.ImageTag) if err != nil { diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml index a87283efca03..2ceabaf0b9de 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml @@ -988,9 +988,6 @@ spec: imageTag: description: ImageTag allows to specify a tag for the image. In case this value is set, kubeadm does not change automatically the version of the above components during upgrades. type: string - type: - description: Type defines the DNS add-on to be used - type: string type: object etcd: description: 'Etcd holds configuration for etcd. NB: This value defaults to a Local (stacked) etcd' diff --git a/controlplane/kubeadm/controllers/controller_test.go b/controlplane/kubeadm/controllers/controller_test.go index 4d0048f483b5..32e0b934930d 100644 --- a/controlplane/kubeadm/controllers/controller_test.go +++ b/controlplane/kubeadm/controllers/controller_test.go @@ -883,7 +883,6 @@ func TestKubeadmControlPlaneReconciler_updateCoreDNS(t *testing.T) { KubeadmConfigSpec: bootstrapv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "k8s.gcr.io", ImageTag: "1.7.2", diff --git a/controlplane/kubeadm/internal/workload_cluster_coredns.go b/controlplane/kubeadm/internal/workload_cluster_coredns.go index ee8754d0d27c..fafeb3470c22 100644 --- a/controlplane/kubeadm/internal/workload_cluster_coredns.go +++ b/controlplane/kubeadm/internal/workload_cluster_coredns.go @@ -86,10 +86,6 @@ func (w *Workload) UpdateCoreDNS(ctx context.Context, kcp *controlplanev1.Kubead } clusterConfig := kcp.Spec.KubeadmConfigSpec.ClusterConfiguration - // Return early if the type is anything other than empty (default), or CoreDNS. - if clusterConfig.DNS.Type != "" && clusterConfig.DNS.Type != bootstrapv1.CoreDNS { - return nil - } // Get the CoreDNS info needed for the upgrade. info, err := w.getCoreDNSInfo(ctx, clusterConfig) diff --git a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go index e77344dce932..62b2775bafcc 100644 --- a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go +++ b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go @@ -40,7 +40,6 @@ func TestUpdateCoreDNS(t *testing.T) { KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: "", ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "", ImageTag: "", @@ -144,9 +143,7 @@ kind: ClusterConfiguration Spec: controlplanev1.KubeadmControlPlaneSpec{ KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ - DNS: bootstrapv1.DNS{ - Type: "", - }, + DNS: bootstrapv1.DNS{}, }, }, }, @@ -164,22 +161,6 @@ kind: ClusterConfiguration objs: []client.Object{badCM}, expectErr: false, }, - { - name: "returns early without error if KCP Cluster config DNS is not empty && not CoreDNS", - kcp: &controlplanev1.KubeadmControlPlane{ - Spec: controlplanev1.KubeadmControlPlaneSpec{ - KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ - ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ - DNS: bootstrapv1.DNS{ - Type: "foobarDNS", - }, - }, - }, - }, - }, - objs: []client.Object{badCM}, - expectErr: false, - }, { name: "returns early without error if CoreDNS info is not found", kcp: validKCP, @@ -204,7 +185,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ // image is older than what's already // installed. @@ -226,7 +206,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ // provide an newer image to update to ImageRepository: "k8s.gcr.io/some-folder/coredns", @@ -248,7 +227,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ // provide an newer image to update to ImageRepository: "k8s.gcr.io/some-folder/coredns", @@ -272,7 +250,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ // provide an newer image to update to ImageRepository: "k8s.gcr.io/some-repo", @@ -298,7 +275,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ // provide an newer image to update to ImageRepository: "k8s.gcr.io/some-repo", @@ -324,7 +300,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "k8s.gcr.io", ImageTag: "1.7.0", @@ -349,7 +324,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "k8s.gcr.io", ImageTag: "1.7.0", @@ -373,7 +347,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "k8s.gcr.io", ImageTag: "v1.8.0", // NOTE: ImageTags requires the v prefix @@ -398,7 +371,6 @@ kind: ClusterConfiguration KubeadmConfigSpec: cabpkv1.KubeadmConfigSpec{ ClusterConfiguration: &bootstrapv1.ClusterConfiguration{ DNS: bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "k8s.gcr.io", ImageTag: "v1.8.0", // NOTE: ImageTags requires the v prefix @@ -952,7 +924,6 @@ scheduler: {}`, delete(emptyCM.Data, "ClusterConfiguration") dns := &bootstrapv1.DNS{ - Type: bootstrapv1.CoreDNS, ImageMeta: bootstrapv1.ImageMeta{ ImageRepository: "gcr.io/example", ImageTag: "1.0.1-somever.1",