diff --git a/bootstrap/kubeadm/api/v1alpha3/conversion.go b/bootstrap/kubeadm/api/v1alpha3/conversion.go index abac455f51df..d70885ecacad 100644 --- a/bootstrap/kubeadm/api/v1alpha3/conversion.go +++ b/bootstrap/kubeadm/api/v1alpha3/conversion.go @@ -90,3 +90,23 @@ func Convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in *k // ClusterConfiguration.UseHyperKubeImage was removed in kubeadm v1alpha4 API return kubeadmbootstrapv1beta1.Convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in, out, s) } + +func Convert_v1alpha4_InitConfiguration_To_v1beta1_InitConfiguration(in *kubeadmbootstrapv1alpha4.InitConfiguration, out *kubeadmbootstrapv1beta1.InitConfiguration, s apiconversion.Scope) error { + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API + return kubeadmbootstrapv1beta1.Convert_v1alpha4_InitConfiguration_To_v1beta1_InitConfiguration(in, out, s) +} + +func Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in *kubeadmbootstrapv1beta1.InitConfiguration, out *kubeadmbootstrapv1alpha4.InitConfiguration, s apiconversion.Scope) error { + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API + return kubeadmbootstrapv1beta1.Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in, out, s) +} + +func Convert_v1alpha4_JoinConfiguration_To_v1beta1_JoinConfiguration(in *kubeadmbootstrapv1alpha4.JoinConfiguration, out *kubeadmbootstrapv1beta1.JoinConfiguration, s apiconversion.Scope) error { + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API + return kubeadmbootstrapv1beta1.Convert_v1alpha4_JoinConfiguration_To_v1beta1_JoinConfiguration(in, out, s) +} + +func Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in *kubeadmbootstrapv1beta1.JoinConfiguration, out *kubeadmbootstrapv1alpha4.JoinConfiguration, s apiconversion.Scope) error { + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API + return kubeadmbootstrapv1beta1.Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in, out, s) +} diff --git a/bootstrap/kubeadm/api/v1alpha3/conversion_test.go b/bootstrap/kubeadm/api/v1alpha3/conversion_test.go index e5b0de2b61b9..93db76d9f3af 100644 --- a/bootstrap/kubeadm/api/v1alpha3/conversion_test.go +++ b/bootstrap/kubeadm/api/v1alpha3/conversion_test.go @@ -23,6 +23,7 @@ import ( "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" + kubeadmbootstrapv1alpha4 "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" ) @@ -45,6 +46,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { KubeadmConfigStatusFuzzer, dnsFuzzer, clusterConfigurationFuzzer, + kubeadmNodeRegistrationOptionsFuzzer, } } @@ -68,3 +70,11 @@ func clusterConfigurationFuzzer(obj *v1beta1.ClusterConfiguration, c fuzz.Contin // ClusterConfiguration.UseHyperKubeImage has been removed in v1alpha4, so setting it to false in order to avoid v1beta1 --> v1alpha4 --> v1beta1 round trip errors. obj.UseHyperKubeImage = false } + +func kubeadmNodeRegistrationOptionsFuzzer(obj *kubeadmbootstrapv1alpha4.NodeRegistrationOptions, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1alpha4 --> v1beta1 -> v1alpha4 round trip errors. + obj.IgnorePreflightErrors = nil +} diff --git a/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go b/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go index a08738c0f55e..b20aa66189ce 100644 --- a/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go +++ b/bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go @@ -203,11 +203,31 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1alpha4.InitConfiguration)(nil), (*v1beta1.InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_InitConfiguration_To_v1beta1_InitConfiguration(a.(*v1alpha4.InitConfiguration), b.(*v1beta1.InitConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1alpha4.JoinConfiguration)(nil), (*v1beta1.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_JoinConfiguration_To_v1beta1_JoinConfiguration(a.(*v1alpha4.JoinConfiguration), b.(*v1beta1.JoinConfiguration), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta1.ClusterConfiguration)(nil), (*v1alpha4.ClusterConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(a.(*v1beta1.ClusterConfiguration), b.(*v1alpha4.ClusterConfiguration), scope) }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta1.InitConfiguration)(nil), (*v1alpha4.InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*v1alpha4.InitConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta1.JoinConfiguration)(nil), (*v1alpha4.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*v1alpha4.JoinConfiguration), scope) + }); err != nil { + return err + } return nil } @@ -403,8 +423,24 @@ func autoConvert_v1alpha3_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *Ku } else { out.ClusterConfiguration = nil } - out.InitConfiguration = (*v1alpha4.InitConfiguration)(unsafe.Pointer(in.InitConfiguration)) - out.JoinConfiguration = (*v1alpha4.JoinConfiguration)(unsafe.Pointer(in.JoinConfiguration)) + if in.InitConfiguration != nil { + in, out := &in.InitConfiguration, &out.InitConfiguration + *out = new(v1alpha4.InitConfiguration) + if err := Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(*in, *out, s); err != nil { + return err + } + } else { + out.InitConfiguration = nil + } + if in.JoinConfiguration != nil { + in, out := &in.JoinConfiguration, &out.JoinConfiguration + *out = new(v1alpha4.JoinConfiguration) + if err := Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(*in, *out, s); err != nil { + return err + } + } else { + out.JoinConfiguration = nil + } out.Files = *(*[]v1alpha4.File)(unsafe.Pointer(&in.Files)) out.DiskSetup = (*v1alpha4.DiskSetup)(unsafe.Pointer(in.DiskSetup)) out.Mounts = *(*[]v1alpha4.MountPoints)(unsafe.Pointer(&in.Mounts)) @@ -433,8 +469,24 @@ func autoConvert_v1alpha4_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *v1 } else { out.ClusterConfiguration = nil } - out.InitConfiguration = (*v1beta1.InitConfiguration)(unsafe.Pointer(in.InitConfiguration)) - out.JoinConfiguration = (*v1beta1.JoinConfiguration)(unsafe.Pointer(in.JoinConfiguration)) + if in.InitConfiguration != nil { + in, out := &in.InitConfiguration, &out.InitConfiguration + *out = new(v1beta1.InitConfiguration) + if err := Convert_v1alpha4_InitConfiguration_To_v1beta1_InitConfiguration(*in, *out, s); err != nil { + return err + } + } else { + out.InitConfiguration = nil + } + if in.JoinConfiguration != nil { + in, out := &in.JoinConfiguration, &out.JoinConfiguration + *out = new(v1beta1.JoinConfiguration) + if err := Convert_v1alpha4_JoinConfiguration_To_v1beta1_JoinConfiguration(*in, *out, s); err != nil { + return err + } + } else { + out.JoinConfiguration = nil + } out.Files = *(*[]File)(unsafe.Pointer(&in.Files)) out.DiskSetup = (*DiskSetup)(unsafe.Pointer(in.DiskSetup)) out.Mounts = *(*[]MountPoints)(unsafe.Pointer(&in.Mounts)) diff --git a/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go b/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go index ef5d79dd3189..b6f9224ff4ab 100644 --- a/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go +++ b/bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go @@ -225,6 +225,10 @@ type NodeRegistrationOptions struct { // Flags have higher priority when parsing. These values are local and specific to the node kubeadm is executing on. // +optional KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"` + + // IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered. + // +optional + IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"` } // Networking contains elements describing cluster's networking configuration. diff --git a/bootstrap/kubeadm/types/utils_test.go b/bootstrap/kubeadm/types/utils_test.go index f8ec5933d182..aec57ed083a9 100644 --- a/bootstrap/kubeadm/types/utils_test.go +++ b/bootstrap/kubeadm/types/utils_test.go @@ -162,6 +162,22 @@ func TestMarshalClusterConfigurationForVersion(t *testing.T) { "scheduler: {}\n", wantErr: false, }, + { + name: "Generates a v1beta3 kubeadm configuration", + args: args{ + capiObj: &bootstrapv1.ClusterConfiguration{}, + version: semver.MustParse("1.22.0"), + }, + want: "apiServer: {}\n" + + "apiVersion: kubeadm.k8s.io/v1beta3\n" + "" + + "controllerManager: {}\n" + + "dns: {}\n" + + "etcd: {}\n" + + "kind: ClusterConfiguration\n" + + "networking: {}\n" + + "scheduler: {}\n", + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -211,6 +227,14 @@ func TestMarshalClusterStatusForVersion(t *testing.T) { "kind: ClusterStatus\n", wantErr: false, }, + { + name: "Fails generating a v1beta3 kubeadm status", + args: args{ + capiObj: &bootstrapv1.ClusterStatus{}, + version: semver.MustParse("1.22.0"), + }, + wantErr: true, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -255,13 +279,38 @@ func TestMarshalInitConfigurationForVersion(t *testing.T) { { name: "Generates a v1beta2 kubeadm configuration", args: args{ - capiObj: &bootstrapv1.InitConfiguration{}, + capiObj: &bootstrapv1.InitConfiguration{ + NodeRegistration: bootstrapv1.NodeRegistrationOptions{ + IgnorePreflightErrors: []string{"some-preflight-check"}, + }, + }, version: semver.MustParse("1.15.0"), }, want: "apiVersion: kubeadm.k8s.io/v1beta2\n" + "kind: InitConfiguration\n" + "localAPIEndpoint: {}\n" + - "nodeRegistration: {}\n", + "nodeRegistration:\n" + + " ignorePreflightErrors:\n" + + " - some-preflight-check\n", + wantErr: false, + }, + { + name: "Generates a v1beta3 kubeadm configuration", + args: args{ + capiObj: &bootstrapv1.InitConfiguration{ + NodeRegistration: bootstrapv1.NodeRegistrationOptions{ + IgnorePreflightErrors: []string{"some-preflight-check"}, + }, + }, + version: semver.MustParse("1.22.0"), + }, + want: "apiVersion: kubeadm.k8s.io/v1beta3\n" + + "kind: InitConfiguration\n" + + "localAPIEndpoint: {}\n" + + "nodeRegistration:\n" + + " ignorePreflightErrors:\n" + + " - some-preflight-check\n" + + " taints: null\n", wantErr: false, }, } @@ -306,13 +355,38 @@ func TestMarshalJoinConfigurationForVersion(t *testing.T) { { name: "Generates a v1beta2 kubeadm configuration", args: args{ - capiObj: &bootstrapv1.JoinConfiguration{}, + capiObj: &bootstrapv1.JoinConfiguration{ + NodeRegistration: bootstrapv1.NodeRegistrationOptions{ + IgnorePreflightErrors: []string{"some-preflight-check"}, + }, + }, version: semver.MustParse("1.15.0"), }, want: "apiVersion: kubeadm.k8s.io/v1beta2\n" + "" + "discovery: {}\n" + "kind: JoinConfiguration\n" + - "nodeRegistration: {}\n", + "nodeRegistration:\n" + + " ignorePreflightErrors:\n" + + " - some-preflight-check\n", + wantErr: false, + }, + { + name: "Generates a v1beta3 kubeadm configuration", + args: args{ + capiObj: &bootstrapv1.JoinConfiguration{ + NodeRegistration: bootstrapv1.NodeRegistrationOptions{ + IgnorePreflightErrors: []string{"some-preflight-check"}, + }, + }, + version: semver.MustParse("1.22.0"), + }, + want: "apiVersion: kubeadm.k8s.io/v1beta3\n" + "" + + "discovery: {}\n" + + "kind: JoinConfiguration\n" + + "nodeRegistration:\n" + + " ignorePreflightErrors:\n" + + " - some-preflight-check\n" + + " taints: null\n", wantErr: false, }, } @@ -371,6 +445,21 @@ func TestUnmarshalClusterConfiguration(t *testing.T) { want: &bootstrapv1.ClusterConfiguration{}, wantErr: false, }, + { + name: "Parses a v1beta3 kubeadm configuration", + args: args{ + yaml: "apiServer: {}\n" + + "apiVersion: kubeadm.k8s.io/v1beta3\n" + "" + + "controllerManager: {}\n" + + "dns: {}\n" + + "etcd: {}\n" + + "kind: ClusterConfiguration\n" + + "networking: {}\n" + + "scheduler: {}\n", + }, + want: &bootstrapv1.ClusterConfiguration{}, + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -417,6 +506,15 @@ func TestUnmarshalClusterStatus(t *testing.T) { want: &bootstrapv1.ClusterStatus{}, wantErr: false, }, + { + name: "Fails parsing a v1beta3 kubeadm configuration", + args: args{ + yaml: "apiEndpoints: null\n" + + "apiVersion: kubeadm.k8s.io/v1beta3\n" + "" + + "kind: ClusterStatus\n", + }, + wantErr: true, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/bootstrap/kubeadm/types/v1beta1/conversion.go b/bootstrap/kubeadm/types/v1beta1/conversion.go index 83f40c7369c8..83a186703b39 100644 --- a/bootstrap/kubeadm/types/v1beta1/conversion.go +++ b/bootstrap/kubeadm/types/v1beta1/conversion.go @@ -19,6 +19,7 @@ package v1beta1 import ( apimachineryconversion "k8s.io/apimachinery/pkg/conversion" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" + v1alpha4 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" "sigs.k8s.io/controller-runtime/pkg/conversion" ) @@ -79,3 +80,8 @@ func Convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in *C // ClusterConfiguration.UseHyperKubeImage was removed in kubeadm v1alpha4 API return autoConvert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in, out, s) } + +func Convert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(in *v1alpha4.NodeRegistrationOptions, out *NodeRegistrationOptions, s apimachineryconversion.Scope) error { + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API + return autoConvert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(in, out, s) +} diff --git a/bootstrap/kubeadm/types/v1beta1/conversion_test.go b/bootstrap/kubeadm/types/v1beta1/conversion_test.go index f4ec090ec779..8302224b6ec5 100644 --- a/bootstrap/kubeadm/types/v1beta1/conversion_test.go +++ b/bootstrap/kubeadm/types/v1beta1/conversion_test.go @@ -23,6 +23,7 @@ import ( "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" + kubeadmbootstrapv1alpha4 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -61,6 +62,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ dnsFuzzer, clusterConfigurationFuzzer, + kubeadmNodeRegistrationOptionsFuzzer, } } @@ -77,3 +79,11 @@ func clusterConfigurationFuzzer(obj *ClusterConfiguration, c fuzz.Continue) { // ClusterConfiguration.UseHyperKubeImage has been removed in v1alpha4, so setting it to false in order to avoid v1beta1 --> v1alpha4 --> v1beta1 round trip errors. obj.UseHyperKubeImage = false } + +func kubeadmNodeRegistrationOptionsFuzzer(obj *kubeadmbootstrapv1alpha4.NodeRegistrationOptions, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1alpha4 --> v1beta1 -> v1alpha4 round trip errors. + obj.IgnorePreflightErrors = nil +} diff --git a/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go b/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go index a842e40c6f0d..18104e8ad5af 100644 --- a/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/v1beta1/zz_generated.conversion.go @@ -232,7 +232,7 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1alpha4.NodeRegistrationOptions)(nil), (*NodeRegistrationOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + if err := s.AddConversionFunc((*v1alpha4.NodeRegistrationOptions)(nil), (*NodeRegistrationOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(a.(*v1alpha4.NodeRegistrationOptions), b.(*NodeRegistrationOptions), scope) }); err != nil { return err @@ -810,10 +810,6 @@ func autoConvert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOpt out.CRISocket = in.CRISocket out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) + // WARNING: in.IgnorePreflightErrors requires manual conversion: does not exist in peer-type return nil } - -// Convert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions is an autogenerated conversion function. -func Convert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(in *v1alpha4.NodeRegistrationOptions, out *NodeRegistrationOptions, s conversion.Scope) error { - return autoConvert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(in, out, s) -} diff --git a/bootstrap/kubeadm/types/v1beta2/types.go b/bootstrap/kubeadm/types/v1beta2/types.go index 0adba068052e..58490deee74a 100644 --- a/bootstrap/kubeadm/types/v1beta2/types.go +++ b/bootstrap/kubeadm/types/v1beta2/types.go @@ -141,6 +141,8 @@ type ClusterConfiguration struct { // ControlPlaneComponent holds settings common to control plane component of the cluster. type ControlPlaneComponent struct { // ExtraArgs is an extra set of flags to pass to the control plane component. + // A key in this map is the flag name as it appears on the + // command line except without leading dash(es). // TODO: This is temporary and ideally we would like to switch all components to // use ComponentConfig + ConfigMaps. ExtraArgs map[string]string `json:"extraArgs,omitempty"` @@ -232,13 +234,15 @@ type NodeRegistrationOptions struct { // Taints specifies the taints the Node API object should be registered with. If this field is unset, i.e. nil, in the `kubeadm init` process // it will be defaulted to []corev1.Taint{'node-role.kubernetes.io/master=""'}. If you don't want to taint your control-plane node, set this field to an - // empty slice, i.e. `taints: {}` in the YAML file. This field is solely used for Node registration. + // empty slice, i.e. `taints: []` in the YAML file. This field is solely used for Node registration. // +optional Taints []corev1.Taint `json:"taints,omitempty"` // KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file // kubeadm writes at runtime for the kubelet to source. This overrides the generic base-level configuration in the kubelet-config-1.X ConfigMap // Flags have higher priority when parsing. These values are local and specific to the node kubeadm is executing on. + // A key in this map is the flag name as it appears on the + // command line except without leading dash(es). // +optional KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"` @@ -310,6 +314,8 @@ type LocalEtcd struct { // ExtraArgs are extra arguments provided to the etcd binary // when run inside a static pod. + // A key in this map is the flag name as it appears on the + // command line except without leading dash(es). ExtraArgs map[string]string `json:"extraArgs,omitempty"` // ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert. @@ -411,7 +417,7 @@ type BootstrapTokenDiscovery struct { // pinning, which can be unsafe. Each hash is specified as ":", // where the only currently supported type is "sha256". This is a hex-encoded // SHA-256 hash of the Subject Public Key Info (SPKI) object in DER-encoded - // ASN.1. These hashes can be calculated using, for example, OpenSSL: + // ASN.1. These hashes can be calculated using, for example, OpenSSL. CACertHashes []string `json:"caCertHashes,omitempty"` // UnsafeSkipCAVerification allows token-based discovery diff --git a/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go b/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go index 5071358ab2a6..ae6431a1b754 100644 --- a/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/v1beta2/zz_generated.conversion.go @@ -805,7 +805,7 @@ func autoConvert_v1beta2_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOpt out.CRISocket = in.CRISocket out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) - // WARNING: in.IgnorePreflightErrors requires manual conversion: does not exist in peer-type + out.IgnorePreflightErrors = *(*[]string)(unsafe.Pointer(&in.IgnorePreflightErrors)) return nil } @@ -814,6 +814,7 @@ func autoConvert_v1alpha4_NodeRegistrationOptions_To_v1beta2_NodeRegistrationOpt out.CRISocket = in.CRISocket out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) + out.IgnorePreflightErrors = *(*[]string)(unsafe.Pointer(&in.IgnorePreflightErrors)) return nil } diff --git a/bootstrap/kubeadm/types/v1beta3/zz_generated.conversion.go b/bootstrap/kubeadm/types/v1beta3/zz_generated.conversion.go index 1c2b6362fea7..610fe377a435 100644 --- a/bootstrap/kubeadm/types/v1beta3/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/v1beta3/zz_generated.conversion.go @@ -780,7 +780,7 @@ func autoConvert_v1beta3_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOpt out.CRISocket = in.CRISocket out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) - // WARNING: in.IgnorePreflightErrors requires manual conversion: does not exist in peer-type + out.IgnorePreflightErrors = *(*[]string)(unsafe.Pointer(&in.IgnorePreflightErrors)) return nil } @@ -789,6 +789,7 @@ func autoConvert_v1alpha4_NodeRegistrationOptions_To_v1beta3_NodeRegistrationOpt out.CRISocket = in.CRISocket out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) + out.IgnorePreflightErrors = *(*[]string)(unsafe.Pointer(&in.IgnorePreflightErrors)) return nil } diff --git a/controlplane/kubeadm/api/v1alpha3/conversion_test.go b/controlplane/kubeadm/api/v1alpha3/conversion_test.go index 59fb9ebbba61..d0f998e1634c 100644 --- a/controlplane/kubeadm/api/v1alpha3/conversion_test.go +++ b/controlplane/kubeadm/api/v1alpha3/conversion_test.go @@ -24,6 +24,7 @@ import ( runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" cabpkv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" + kubeadmbootstrapv1alpha4 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4" kubeadmv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/v1beta1" "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1alpha4" utilconversion "sigs.k8s.io/cluster-api/util/conversion" @@ -53,6 +54,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { cabpkBootstrapTokenStringFuzzer, dnsFuzzer, kubeadmClusterConfigurationFuzzer, + kubeadmNodeRegistrationOptionsFuzzer, } } @@ -78,3 +80,11 @@ func kubeadmClusterConfigurationFuzzer(obj *kubeadmv1beta1.ClusterConfiguration, // ClusterConfiguration.UseHyperKubeImage has been removed in v1alpha4, so setting it to false in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors. obj.UseHyperKubeImage = false } + +func kubeadmNodeRegistrationOptionsFuzzer(obj *kubeadmbootstrapv1alpha4.NodeRegistrationOptions, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1alpha4 --> v1beta1 -> v1alpha4 round trip errors. + obj.IgnorePreflightErrors = nil +}