diff --git a/bootstrap/kubeadm/api/v1alpha3/conversion.go b/bootstrap/kubeadm/api/v1alpha3/conversion.go index 35a84e2705f4..d6a772d806a2 100644 --- a/bootstrap/kubeadm/api/v1alpha3/conversion.go +++ b/bootstrap/kubeadm/api/v1alpha3/conversion.go @@ -53,6 +53,12 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.Ignition = restored.Spec.Ignition + if restored.Spec.InitConfiguration != nil { + dst.Spec.InitConfiguration.Patches = restored.Spec.InitConfiguration.Patches + } + if restored.Spec.JoinConfiguration != nil { + dst.Spec.JoinConfiguration.Patches = restored.Spec.JoinConfiguration.Patches + } return nil } @@ -112,6 +118,12 @@ func (src *KubeadmConfigTemplate) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.Template.Spec.Ignition = restored.Spec.Template.Spec.Ignition + if restored.Spec.Template.Spec.InitConfiguration != nil { + dst.Spec.Template.Spec.InitConfiguration.Patches = restored.Spec.Template.Spec.InitConfiguration.Patches + } + if restored.Spec.Template.Spec.JoinConfiguration != nil { + dst.Spec.Template.Spec.JoinConfiguration.Patches = restored.Spec.Template.Spec.JoinConfiguration.Patches + } return nil } @@ -187,3 +199,4 @@ func Convert_v1beta1_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *bootstr // KubeadmConfigSpec.Ignition does not exist in kubeadm v1alpha3 API. return autoConvert_v1beta1_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in, out, s) } + diff --git a/bootstrap/kubeadm/api/v1alpha4/conversion.go b/bootstrap/kubeadm/api/v1alpha4/conversion.go index 9608da608700..89c444aeecdb 100644 --- a/bootstrap/kubeadm/api/v1alpha4/conversion.go +++ b/bootstrap/kubeadm/api/v1alpha4/conversion.go @@ -38,6 +38,12 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.Ignition = restored.Spec.Ignition + if restored.Spec.InitConfiguration != nil { + dst.Spec.InitConfiguration.Patches = restored.Spec.InitConfiguration.Patches + } + if restored.Spec.JoinConfiguration != nil { + dst.Spec.JoinConfiguration.Patches = restored.Spec.JoinConfiguration.Patches + } return nil } @@ -78,6 +84,12 @@ func (src *KubeadmConfigTemplate) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.Template.Spec.Ignition = restored.Spec.Template.Spec.Ignition + if restored.Spec.Template.Spec.InitConfiguration != nil { + dst.Spec.Template.Spec.InitConfiguration.Patches = restored.Spec.Template.Spec.InitConfiguration.Patches + } + if restored.Spec.Template.Spec.JoinConfiguration != nil { + dst.Spec.Template.Spec.JoinConfiguration.Patches = restored.Spec.Template.Spec.JoinConfiguration.Patches + } return nil } @@ -109,3 +121,13 @@ func Convert_v1beta1_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *bootstr // KubeadmConfigSpec.Ignition does not exist in kubeadm v1alpha4 API. return autoConvert_v1beta1_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in, out, s) } + +func Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in *bootstrapv1.InitConfiguration, out *InitConfiguration, s apiconversion.Scope) error { + // InitConfiguration.Patches does not exist in kubeadm v1alpha4 API. + return autoConvert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in, out, s) +} + +func Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *JoinConfiguration, s apiconversion.Scope) error { + // InitConfiguration.Patches does not exist in kubeadm v1alpha4 API. + return autoConvert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in, out, s) +} diff --git a/bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go b/bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go index 6cd521551442..7afa7352185d 100644 --- a/bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go +++ b/bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go @@ -235,21 +235,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*InitConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*JoinConfiguration)(nil), (*v1beta1.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_JoinConfiguration_To_v1beta1_JoinConfiguration(a.(*JoinConfiguration), b.(*v1beta1.JoinConfiguration), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*JoinConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*JoinControlPlane)(nil), (*v1beta1.JoinControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_JoinControlPlane_To_v1beta1_JoinControlPlane(a.(*JoinControlPlane), b.(*v1beta1.JoinControlPlane), scope) }); err != nil { @@ -405,6 +395,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta1.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*InitConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta1.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*JoinConfiguration), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta1.KubeadmConfigSpec)(nil), (*KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(a.(*v1beta1.KubeadmConfigSpec), b.(*KubeadmConfigSpec), scope) }); err != nil { @@ -949,14 +949,10 @@ func autoConvert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in *v1b if err := Convert_v1beta1_APIEndpoint_To_v1alpha4_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err } + // WARNING: in.Patches requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration is an autogenerated conversion function. -func Convert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in *v1beta1.InitConfiguration, out *InitConfiguration, s conversion.Scope) error { - return autoConvert_v1beta1_InitConfiguration_To_v1alpha4_InitConfiguration(in, out, s) -} - func autoConvert_v1alpha4_JoinConfiguration_To_v1beta1_JoinConfiguration(in *JoinConfiguration, out *v1beta1.JoinConfiguration, s conversion.Scope) error { if err := Convert_v1alpha4_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { return err @@ -983,14 +979,10 @@ func autoConvert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in *v1b return err } out.ControlPlane = (*JoinControlPlane)(unsafe.Pointer(in.ControlPlane)) + // WARNING: in.Patches requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration is an autogenerated conversion function. -func Convert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in *v1beta1.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error { - return autoConvert_v1beta1_JoinConfiguration_To_v1alpha4_JoinConfiguration(in, out, s) -} - func autoConvert_v1alpha4_JoinControlPlane_To_v1beta1_JoinControlPlane(in *JoinControlPlane, out *v1beta1.JoinControlPlane, s conversion.Scope) error { if err := Convert_v1alpha4_APIEndpoint_To_v1beta1_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err @@ -1091,8 +1083,24 @@ func Convert_v1beta1_KubeadmConfigList_To_v1alpha4_KubeadmConfigList(in *v1beta1 func autoConvert_v1alpha4_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(in *KubeadmConfigSpec, out *v1beta1.KubeadmConfigSpec, s conversion.Scope) error { out.ClusterConfiguration = (*v1beta1.ClusterConfiguration)(unsafe.Pointer(in.ClusterConfiguration)) - 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 = *(*[]v1beta1.File)(unsafe.Pointer(&in.Files)) out.DiskSetup = (*v1beta1.DiskSetup)(unsafe.Pointer(in.DiskSetup)) out.Mounts = *(*[]v1beta1.MountPoints)(unsafe.Pointer(&in.Mounts)) @@ -1113,8 +1121,24 @@ func Convert_v1alpha4_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(in *Kubeadm func autoConvert_v1beta1_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *v1beta1.KubeadmConfigSpec, out *KubeadmConfigSpec, s conversion.Scope) error { out.ClusterConfiguration = (*ClusterConfiguration)(unsafe.Pointer(in.ClusterConfiguration)) - out.InitConfiguration = (*InitConfiguration)(unsafe.Pointer(in.InitConfiguration)) - out.JoinConfiguration = (*JoinConfiguration)(unsafe.Pointer(in.JoinConfiguration)) + if in.InitConfiguration != nil { + in, out := &in.InitConfiguration, &out.InitConfiguration + *out = new(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(JoinConfiguration) + if err := Convert_v1beta1_JoinConfiguration_To_v1alpha4_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/v1beta1/kubeadm_types.go b/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go index 6304e0900778..354d777d5d31 100644 --- a/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go +++ b/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go @@ -53,6 +53,11 @@ type InitConfiguration struct { // fails you may set the desired value here. // +optional LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"` + + // Patches contains options related to applying patches to components deployed by kubeadm during + // "kubeadm init". The minimum kubernetes version needed to support Patches is v1.22 + // +optional + Patches *Patches `json:"patches,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -360,6 +365,11 @@ type JoinConfiguration struct { // If nil, no additional control plane instance will be deployed. // +optional ControlPlane *JoinControlPlane `json:"controlPlane,omitempty"` + + // Patches contains options related to applying patches to components deployed by kubeadm during + // "kubeadm join". The minimum kubernetes version needed to support Patches is v1.22 + // +optional + Patches *Patches `json:"patches,omitempty"` } // JoinControlPlane contains elements describing an additional control plane instance to be deployed on the joining node. @@ -500,3 +510,19 @@ func NewBootstrapTokenString(token string) (*BootstrapTokenString, error) { return &BootstrapTokenString{ID: substrs[1], Secret: substrs[2]}, nil } + +// Patches contains options related to applying patches to components deployed by kubeadm. +type Patches struct { + // Directory is a path to a directory that contains files named "target[suffix][+patchtype].extension". + // For example, "kube-apiserver0+merge.yaml" or just "etcd.json". "target" can be one of + // "kube-apiserver", "kube-controller-manager", "kube-scheduler", "etcd". "patchtype" can be one + // of "strategic" "merge" or "json" and they match the patch formats supported by kubectl. + // The default "patchtype" is "strategic". "extension" must be either "json" or "yaml". + // "suffix" is an optional string that can be used to determine which patches are applied + // first alpha-numerically. + // These files can be written into the target directory via KubeadmConfig.Files which + // specifies additional files to be created on the machine, either with content inline or + // by referencing a secret. + // +optional + Directory string `json:"directory,omitempty"` +} diff --git a/bootstrap/kubeadm/api/v1beta1/zz_generated.deepcopy.go b/bootstrap/kubeadm/api/v1beta1/zz_generated.deepcopy.go index 80ce9d284902..5af4c0d9f029 100644 --- a/bootstrap/kubeadm/api/v1beta1/zz_generated.deepcopy.go +++ b/bootstrap/kubeadm/api/v1beta1/zz_generated.deepcopy.go @@ -522,6 +522,11 @@ func (in *InitConfiguration) DeepCopyInto(out *InitConfiguration) { } in.NodeRegistration.DeepCopyInto(&out.NodeRegistration) out.LocalAPIEndpoint = in.LocalAPIEndpoint + if in.Patches != nil { + in, out := &in.Patches, &out.Patches + *out = new(Patches) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitConfiguration. @@ -553,6 +558,11 @@ func (in *JoinConfiguration) DeepCopyInto(out *JoinConfiguration) { *out = new(JoinControlPlane) **out = **in } + if in.Patches != nil { + in, out := &in.Patches, &out.Patches + *out = new(Patches) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JoinConfiguration. @@ -1001,6 +1011,21 @@ func (in *Partition) DeepCopy() *Partition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Patches) DeepCopyInto(out *Patches) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Patches. +func (in *Patches) DeepCopy() *Patches { + if in == nil { + return nil + } + out := new(Patches) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecretFileSource) DeepCopyInto(out *SecretFileSource) { *out = *in 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 e8052539a3ba..37b1a31b1e01 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 @@ -2645,6 +2645,27 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying patches + to components deployed by kubeadm during "kubeadm init". The + minimum kubernetes version needed to support Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory that contains + files named "target[suffix][+patchtype].extension". For + example, "kube-apiserver0+merge.yaml" or just "etcd.json". + "target" can be one of "kube-apiserver", "kube-controller-manager", + "kube-scheduler", "etcd". "patchtype" can be one of "strategic" + "merge" or "json" and they match the patch formats supported + by kubectl. The default "patchtype" is "strategic". "extension" + must be either "json" or "yaml". "suffix" is an optional + string that can be used to determine which patches are applied + first alpha-numerically. These files can be written into + the target directory via KubeadmConfig.Files which specifies + additional files to be created on the machine, either with + content inline or by referencing a secret. + type: string + type: object type: object joinConfiguration: description: JoinConfiguration is the kubeadm configuration for the @@ -2827,6 +2848,27 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying patches + to components deployed by kubeadm during "kubeadm join". The + minimum kubernetes version needed to support Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory that contains + files named "target[suffix][+patchtype].extension". For + example, "kube-apiserver0+merge.yaml" or just "etcd.json". + "target" can be one of "kube-apiserver", "kube-controller-manager", + "kube-scheduler", "etcd". "patchtype" can be one of "strategic" + "merge" or "json" and they match the patch formats supported + by kubectl. The default "patchtype" is "strategic". "extension" + must be either "json" or "yaml". "suffix" is an optional + string that can be used to determine which patches are applied + first alpha-numerically. These files can be written into + the target directory via KubeadmConfig.Files which specifies + additional files to be created on the machine, either with + content inline or by referencing a secret. + type: string + type: object type: object mounts: description: Mounts specifies a list of mount points to be setup. 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 7c19a8c0a1eb..b93d01270ee1 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 @@ -2674,6 +2674,30 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying + patches to components deployed by kubeadm during "kubeadm + init". The minimum kubernetes version needed to support + Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory that + contains files named "target[suffix][+patchtype].extension". + For example, "kube-apiserver0+merge.yaml" or just + "etcd.json". "target" can be one of "kube-apiserver", + "kube-controller-manager", "kube-scheduler", "etcd". + "patchtype" can be one of "strategic" "merge" or + "json" and they match the patch formats supported + by kubectl. The default "patchtype" is "strategic". + "extension" must be either "json" or "yaml". "suffix" + is an optional string that can be used to determine + which patches are applied first alpha-numerically. + These files can be written into the target directory + via KubeadmConfig.Files which specifies additional + files to be created on the machine, either with + content inline or by referencing a secret. + type: string + type: object type: object joinConfiguration: description: JoinConfiguration is the kubeadm configuration @@ -2868,6 +2892,30 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying + patches to components deployed by kubeadm during "kubeadm + join". The minimum kubernetes version needed to support + Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory that + contains files named "target[suffix][+patchtype].extension". + For example, "kube-apiserver0+merge.yaml" or just + "etcd.json". "target" can be one of "kube-apiserver", + "kube-controller-manager", "kube-scheduler", "etcd". + "patchtype" can be one of "strategic" "merge" or + "json" and they match the patch formats supported + by kubectl. The default "patchtype" is "strategic". + "extension" must be either "json" or "yaml". "suffix" + is an optional string that can be used to determine + which patches are applied first alpha-numerically. + These files can be written into the target directory + via KubeadmConfig.Files which specifies additional + files to be created on the machine, either with + content inline or by referencing a secret. + type: string + type: object type: object mounts: description: Mounts specifies a list of mount points to be diff --git a/bootstrap/kubeadm/types/upstreamv1beta1/conversion.go b/bootstrap/kubeadm/types/upstreamv1beta1/conversion.go index c74dee3fce54..e893686d52e1 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta1/conversion.go +++ b/bootstrap/kubeadm/types/upstreamv1beta1/conversion.go @@ -85,3 +85,13 @@ func Convert_v1beta1_NodeRegistrationOptions_To_upstreamv1beta1_NodeRegistration // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API return autoConvert_v1beta1_NodeRegistrationOptions_To_upstreamv1beta1_NodeRegistrationOptions(in, out, s) } + +func Convert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in *bootstrapv1.InitConfiguration, out *InitConfiguration, s apimachineryconversion.Scope) error { + // InitConfiguration.Patches does not exist in kubeadm v1beta1 API + return autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in, out, s) +} + +func Convert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *JoinConfiguration, s apimachineryconversion.Scope) error { + // JoinConfiguration.Patches does not exist in kubeadm v1beta1 API + return autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in, out, s) +} diff --git a/bootstrap/kubeadm/types/upstreamv1beta1/conversion_test.go b/bootstrap/kubeadm/types/upstreamv1beta1/conversion_test.go index ebe8ad97fc05..89e5f0141e3f 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta1/conversion_test.go +++ b/bootstrap/kubeadm/types/upstreamv1beta1/conversion_test.go @@ -63,6 +63,8 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { dnsFuzzer, clusterConfigurationFuzzer, kubeadmNodeRegistrationOptionsFuzzer, + kubeadmInitConfigurationFuzzer, + kubeadmJoinConfigurationFuzzer, } } @@ -87,3 +89,19 @@ func kubeadmNodeRegistrationOptionsFuzzer(obj *bootstrapv1.NodeRegistrationOptio // v1alpha4 --> v1beta1 -> v1alpha4 round trip errors. obj.IgnorePreflightErrors = nil } + +func kubeadmInitConfigurationFuzzer(obj *bootstrapv1.InitConfiguration, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // InitConfiguration.Patches does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1beta1 --> upstream v1beta1 -> v1beta1 round trip errors. + obj.Patches = nil +} + +func kubeadmJoinConfigurationFuzzer(obj *bootstrapv1.JoinConfiguration, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // JoinConfiguration.Patches does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1beta1 --> upstream v1beta1 -> v1beta1 round trip errors. + obj.Patches = nil +} diff --git a/bootstrap/kubeadm/types/upstreamv1beta1/zz_generated.conversion.go b/bootstrap/kubeadm/types/upstreamv1beta1/zz_generated.conversion.go index 3f9eff3ec802..f3878c261262 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta1/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/upstreamv1beta1/zz_generated.conversion.go @@ -183,21 +183,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*InitConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*JoinConfiguration)(nil), (*v1beta1.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_upstreamv1beta1_JoinConfiguration_To_v1beta1_JoinConfiguration(a.(*JoinConfiguration), b.(*v1beta1.JoinConfiguration), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*JoinConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*JoinControlPlane)(nil), (*v1beta1.JoinControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_upstreamv1beta1_JoinControlPlane_To_v1beta1_JoinControlPlane(a.(*JoinControlPlane), b.(*v1beta1.JoinControlPlane), scope) }); err != nil { @@ -243,6 +233,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta1.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*InitConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta1.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*JoinConfiguration), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta1.NodeRegistrationOptions)(nil), (*NodeRegistrationOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_NodeRegistrationOptions_To_upstreamv1beta1_NodeRegistrationOptions(a.(*v1beta1.NodeRegistrationOptions), b.(*NodeRegistrationOptions), scope) }); err != nil { @@ -671,14 +671,10 @@ func autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration( if err := Convert_v1beta1_APIEndpoint_To_upstreamv1beta1_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err } + // WARNING: in.Patches requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration is an autogenerated conversion function. -func Convert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in *v1beta1.InitConfiguration, out *InitConfiguration, s conversion.Scope) error { - return autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in, out, s) -} - func autoConvert_upstreamv1beta1_JoinConfiguration_To_v1beta1_JoinConfiguration(in *JoinConfiguration, out *v1beta1.JoinConfiguration, s conversion.Scope) error { if err := Convert_upstreamv1beta1_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { return err @@ -705,14 +701,10 @@ func autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration( return err } out.ControlPlane = (*JoinControlPlane)(unsafe.Pointer(in.ControlPlane)) + // WARNING: in.Patches requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration is an autogenerated conversion function. -func Convert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in *v1beta1.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error { - return autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in, out, s) -} - func autoConvert_upstreamv1beta1_JoinControlPlane_To_v1beta1_JoinControlPlane(in *JoinControlPlane, out *v1beta1.JoinControlPlane, s conversion.Scope) error { if err := Convert_upstreamv1beta1_APIEndpoint_To_v1beta1_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err diff --git a/bootstrap/kubeadm/types/upstreamv1beta2/conversion.go b/bootstrap/kubeadm/types/upstreamv1beta2/conversion.go index bcbd15063dbb..efbb99b7e221 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta2/conversion.go +++ b/bootstrap/kubeadm/types/upstreamv1beta2/conversion.go @@ -82,3 +82,13 @@ func Convert_upstreamv1beta2_ClusterConfiguration_To_v1beta1_ClusterConfiguratio // ClusterConfiguration.UseHyperKubeImage was removed in kubeadm v1alpha4 API return autoConvert_upstreamv1beta2_ClusterConfiguration_To_v1beta1_ClusterConfiguration(in, out, s) } + +func Convert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration(in *bootstrapv1.InitConfiguration, out *InitConfiguration, s apimachineryconversion.Scope) error { + // InitConfiguration.Patches does not exist in kubeadm v1beta2 API + return autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration(in, out, s) +} + +func Convert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *JoinConfiguration, s apimachineryconversion.Scope) error { + // JoinConfiguration.Patches does not exist in kubeadm v1beta2 API + return autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration(in, out, s) +} diff --git a/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go b/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go index 197a30bda753..4a7ff8afe5df 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go +++ b/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go @@ -64,6 +64,8 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { joinControlPlanesFuzzer, dnsFuzzer, clusterConfigurationFuzzer, + kubeadmInitConfigurationFuzzer, + kubeadmJoinConfigurationFuzzer, } } @@ -94,3 +96,19 @@ func clusterConfigurationFuzzer(obj *ClusterConfiguration, c fuzz.Continue) { // ClusterConfiguration.UseHyperKubeImage has been removed in v1alpha4, so setting it to false in order to avoid v1beta2 --> v1alpha4 --> v1beta2 round trip errors. obj.UseHyperKubeImage = false } + +func kubeadmInitConfigurationFuzzer(obj *bootstrapv1.InitConfiguration, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // InitConfiguration.Patches does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1beta1 --> upstream v1beta2 -> v1beta1 round trip errors. + obj.Patches = nil +} + +func kubeadmJoinConfigurationFuzzer(obj *bootstrapv1.JoinConfiguration, c fuzz.Continue) { + c.FuzzNoCustom(obj) + + // JoinConfiguration.Patches does not exist in kubeadm v1beta1 API, so setting it to nil in order to avoid + // v1beta1 --> upstream v1beta2 -> v1beta1 round trip errors. + obj.Patches = nil +} diff --git a/bootstrap/kubeadm/types/upstreamv1beta2/zz_generated.conversion.go b/bootstrap/kubeadm/types/upstreamv1beta2/zz_generated.conversion.go index f0c3817c347a..ef6dbc7c97e9 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta2/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/upstreamv1beta2/zz_generated.conversion.go @@ -178,21 +178,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*InitConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*JoinConfiguration)(nil), (*v1beta1.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_upstreamv1beta2_JoinConfiguration_To_v1beta1_JoinConfiguration(a.(*JoinConfiguration), b.(*v1beta1.JoinConfiguration), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*JoinConfiguration), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*v1beta1.JoinControlPlane)(nil), (*JoinControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_JoinControlPlane_To_upstreamv1beta2_JoinControlPlane(a.(*v1beta1.JoinControlPlane), b.(*JoinControlPlane), scope) }); err != nil { @@ -248,6 +238,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta1.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration(a.(*v1beta1.InitConfiguration), b.(*InitConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta1.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration(a.(*v1beta1.JoinConfiguration), b.(*JoinConfiguration), scope) + }); err != nil { + return err + } return nil } @@ -667,14 +667,10 @@ func autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration( if err := Convert_v1beta1_APIEndpoint_To_upstreamv1beta2_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err } + // WARNING: in.Patches requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration is an autogenerated conversion function. -func Convert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration(in *v1beta1.InitConfiguration, out *InitConfiguration, s conversion.Scope) error { - return autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta2_InitConfiguration(in, out, s) -} - func autoConvert_upstreamv1beta2_JoinConfiguration_To_v1beta1_JoinConfiguration(in *JoinConfiguration, out *v1beta1.JoinConfiguration, s conversion.Scope) error { if err := Convert_upstreamv1beta2_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { return err @@ -717,14 +713,10 @@ func autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration( } else { out.ControlPlane = nil } + // WARNING: in.Patches requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration is an autogenerated conversion function. -func Convert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration(in *v1beta1.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error { - return autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta2_JoinConfiguration(in, out, s) -} - func autoConvert_upstreamv1beta2_JoinControlPlane_To_v1beta1_JoinControlPlane(in *JoinControlPlane, out *v1beta1.JoinControlPlane, s conversion.Scope) error { if err := Convert_upstreamv1beta2_APIEndpoint_To_v1beta1_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err diff --git a/bootstrap/kubeadm/types/upstreamv1beta3/types.go b/bootstrap/kubeadm/types/upstreamv1beta3/types.go index 151ea7830758..ba64d712a1ec 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta3/types.go +++ b/bootstrap/kubeadm/types/upstreamv1beta3/types.go @@ -60,6 +60,11 @@ type InitConfiguration struct { // The flag "--skip-phases" takes precedence over this field. // +optional SkipPhases []string `json:"skipPhases,omitempty"` + + // Patches contains options related to applying patches to components deployed by kubeadm during + // "kubeadm init". The minimum kubernetes version needed to support Patches is v1.22 + // +optional + Patches *Patches `json:"patches,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -346,6 +351,11 @@ type JoinConfiguration struct { // The flag "--skip-phases" takes precedence over this field. // +optional SkipPhases []string `json:"skipPhases,omitempty"` + + // Patches contains options related to applying patches to components deployed by kubeadm during + // "kubeadm init". The minimum kubernetes version needed to support Patches is v1.22 + // +optional + Patches *Patches `json:"patches,omitempty"` } // JoinControlPlane contains elements describing an additional control plane instance to be deployed on the joining node. @@ -433,3 +443,16 @@ type HostPathMount struct { // +optional PathType corev1.HostPathType `json:"pathType,omitempty"` } + +// Patches contains options related to applying patches to components deployed by kubeadm. +type Patches struct { + // Directory is a path to a directory that contains files named "target[suffix][+patchtype].extension". + // For example, "kube-apiserver0+merge.yaml" or just "etcd.json". "target" can be one of + // "kube-apiserver", "kube-controller-manager", "kube-scheduler", "etcd". "patchtype" can be one + // of "strategic" "merge" or "json" and they match the patch formats supported by kubectl. + // The default "patchtype" is "strategic". "extension" must be either "json" or "yaml". + // "suffix" is an optional string that can be used to determine which patches are applied + // first alpha-numerically. + // +optional + Directory string `json:"directory,omitempty"` +} diff --git a/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.conversion.go b/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.conversion.go index 43b7c73051c3..265ced1207ad 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.conversion.go +++ b/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.conversion.go @@ -218,6 +218,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*Patches)(nil), (*v1beta1.Patches)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_upstreamv1beta3_Patches_To_v1beta1_Patches(a.(*Patches), b.(*v1beta1.Patches), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta1.Patches)(nil), (*Patches)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Patches_To_upstreamv1beta3_Patches(a.(*v1beta1.Patches), b.(*Patches), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*InitConfiguration)(nil), (*v1beta1.InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_upstreamv1beta3_InitConfiguration_To_v1beta1_InitConfiguration(a.(*InitConfiguration), b.(*v1beta1.InitConfiguration), scope) }); err != nil { @@ -635,6 +645,7 @@ func autoConvert_upstreamv1beta3_InitConfiguration_To_v1beta1_InitConfiguration( } // WARNING: in.CertificateKey requires manual conversion: does not exist in peer-type // WARNING: in.SkipPhases requires manual conversion: does not exist in peer-type + out.Patches = (*v1beta1.Patches)(unsafe.Pointer(in.Patches)) return nil } @@ -646,6 +657,7 @@ func autoConvert_v1beta1_InitConfiguration_To_upstreamv1beta3_InitConfiguration( if err := Convert_v1beta1_APIEndpoint_To_upstreamv1beta3_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil { return err } + out.Patches = (*Patches)(unsafe.Pointer(in.Patches)) return nil } @@ -672,6 +684,7 @@ func autoConvert_upstreamv1beta3_JoinConfiguration_To_v1beta1_JoinConfiguration( out.ControlPlane = nil } // WARNING: in.SkipPhases requires manual conversion: does not exist in peer-type + out.Patches = (*v1beta1.Patches)(unsafe.Pointer(in.Patches)) return nil } @@ -692,6 +705,7 @@ func autoConvert_v1beta1_JoinConfiguration_To_upstreamv1beta3_JoinConfiguration( } else { out.ControlPlane = nil } + out.Patches = (*Patches)(unsafe.Pointer(in.Patches)) return nil } @@ -798,3 +812,23 @@ func autoConvert_v1beta1_NodeRegistrationOptions_To_upstreamv1beta3_NodeRegistra func Convert_v1beta1_NodeRegistrationOptions_To_upstreamv1beta3_NodeRegistrationOptions(in *v1beta1.NodeRegistrationOptions, out *NodeRegistrationOptions, s conversion.Scope) error { return autoConvert_v1beta1_NodeRegistrationOptions_To_upstreamv1beta3_NodeRegistrationOptions(in, out, s) } + +func autoConvert_upstreamv1beta3_Patches_To_v1beta1_Patches(in *Patches, out *v1beta1.Patches, s conversion.Scope) error { + out.Directory = in.Directory + return nil +} + +// Convert_upstreamv1beta3_Patches_To_v1beta1_Patches is an autogenerated conversion function. +func Convert_upstreamv1beta3_Patches_To_v1beta1_Patches(in *Patches, out *v1beta1.Patches, s conversion.Scope) error { + return autoConvert_upstreamv1beta3_Patches_To_v1beta1_Patches(in, out, s) +} + +func autoConvert_v1beta1_Patches_To_upstreamv1beta3_Patches(in *v1beta1.Patches, out *Patches, s conversion.Scope) error { + out.Directory = in.Directory + return nil +} + +// Convert_v1beta1_Patches_To_upstreamv1beta3_Patches is an autogenerated conversion function. +func Convert_v1beta1_Patches_To_upstreamv1beta3_Patches(in *v1beta1.Patches, out *Patches, s conversion.Scope) error { + return autoConvert_v1beta1_Patches_To_upstreamv1beta3_Patches(in, out, s) +} diff --git a/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.deepcopy.go b/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.deepcopy.go index 3bc51cda8576..07902b44e68a 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.deepcopy.go +++ b/bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.deepcopy.go @@ -360,6 +360,11 @@ func (in *InitConfiguration) DeepCopyInto(out *InitConfiguration) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.Patches != nil { + in, out := &in.Patches, &out.Patches + *out = new(Patches) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitConfiguration. @@ -396,6 +401,11 @@ func (in *JoinConfiguration) DeepCopyInto(out *JoinConfiguration) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.Patches != nil { + in, out := &in.Patches, &out.Patches + *out = new(Patches) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JoinConfiguration. @@ -513,3 +523,18 @@ func (in *NodeRegistrationOptions) DeepCopy() *NodeRegistrationOptions { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Patches) DeepCopyInto(out *Patches) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Patches. +func (in *Patches) DeepCopy() *Patches { + if in == nil { + return nil + } + out := new(Patches) + in.DeepCopyInto(out) + return out +} diff --git a/controlplane/kubeadm/api/v1alpha3/conversion.go b/controlplane/kubeadm/api/v1alpha3/conversion.go index 648aaf65fb83..cd7c1913a743 100644 --- a/controlplane/kubeadm/api/v1alpha3/conversion.go +++ b/controlplane/kubeadm/api/v1alpha3/conversion.go @@ -56,6 +56,12 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.KubeadmConfigSpec.Ignition = restored.Spec.KubeadmConfigSpec.Ignition + if restored.Spec.KubeadmConfigSpec.InitConfiguration != nil { + dst.Spec.KubeadmConfigSpec.InitConfiguration.Patches = restored.Spec.KubeadmConfigSpec.InitConfiguration.Patches + } + if restored.Spec.KubeadmConfigSpec.JoinConfiguration != nil { + dst.Spec.KubeadmConfigSpec.JoinConfiguration.Patches = restored.Spec.KubeadmConfigSpec.JoinConfiguration.Patches + } return nil } diff --git a/controlplane/kubeadm/api/v1alpha4/conversion.go b/controlplane/kubeadm/api/v1alpha4/conversion.go index 1332b29e8b81..7147736f29d9 100644 --- a/controlplane/kubeadm/api/v1alpha4/conversion.go +++ b/controlplane/kubeadm/api/v1alpha4/conversion.go @@ -39,6 +39,12 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.KubeadmConfigSpec.Ignition = restored.Spec.KubeadmConfigSpec.Ignition + if restored.Spec.KubeadmConfigSpec.InitConfiguration != nil { + dst.Spec.KubeadmConfigSpec.InitConfiguration.Patches = restored.Spec.KubeadmConfigSpec.InitConfiguration.Patches + } + if restored.Spec.KubeadmConfigSpec.JoinConfiguration != nil { + dst.Spec.KubeadmConfigSpec.JoinConfiguration.Patches = restored.Spec.KubeadmConfigSpec.JoinConfiguration.Patches + } return nil } @@ -81,6 +87,12 @@ func (src *KubeadmControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.KubeadmConfigSpec.Ignition = restored.Spec.Template.Spec.KubeadmConfigSpec.Ignition dst.Spec.Template.Spec.MachineTemplate = restored.Spec.Template.Spec.MachineTemplate + if restored.Spec.Template.Spec.KubeadmConfigSpec.InitConfiguration != nil { + dst.Spec.Template.Spec.KubeadmConfigSpec.InitConfiguration.Patches = restored.Spec.Template.Spec.KubeadmConfigSpec.InitConfiguration.Patches + } + if restored.Spec.Template.Spec.KubeadmConfigSpec.JoinConfiguration != nil { + dst.Spec.Template.Spec.KubeadmConfigSpec.JoinConfiguration.Patches = restored.Spec.Template.Spec.KubeadmConfigSpec.JoinConfiguration.Patches + } return 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 abade5b231b6..d44fe1199000 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 @@ -3112,6 +3112,29 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying + patches to components deployed by kubeadm during "kubeadm + init". The minimum kubernetes version needed to support + Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory that contains + files named "target[suffix][+patchtype].extension". + For example, "kube-apiserver0+merge.yaml" or just "etcd.json". + "target" can be one of "kube-apiserver", "kube-controller-manager", + "kube-scheduler", "etcd". "patchtype" can be one of + "strategic" "merge" or "json" and they match the patch + formats supported by kubectl. The default "patchtype" + is "strategic". "extension" must be either "json" or + "yaml". "suffix" is an optional string that can be used + to determine which patches are applied first alpha-numerically. + These files can be written into the target directory + via KubeadmConfig.Files which specifies additional files + to be created on the machine, either with content inline + or by referencing a secret. + type: string + type: object type: object joinConfiguration: description: JoinConfiguration is the kubeadm configuration for @@ -3301,6 +3324,29 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying + patches to components deployed by kubeadm during "kubeadm + join". The minimum kubernetes version needed to support + Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory that contains + files named "target[suffix][+patchtype].extension". + For example, "kube-apiserver0+merge.yaml" or just "etcd.json". + "target" can be one of "kube-apiserver", "kube-controller-manager", + "kube-scheduler", "etcd". "patchtype" can be one of + "strategic" "merge" or "json" and they match the patch + formats supported by kubectl. The default "patchtype" + is "strategic". "extension" must be either "json" or + "yaml". "suffix" is an optional string that can be used + to determine which patches are applied first alpha-numerically. + These files can be written into the target directory + via KubeadmConfig.Files which specifies additional files + to be created on the machine, either with content inline + or by referencing a secret. + type: string + type: object type: object mounts: description: Mounts specifies a list of mount points to be setup. diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml index f40ba5f39604..640d78c33250 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml @@ -1911,6 +1911,31 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying + patches to components deployed by kubeadm during + "kubeadm init". The minimum kubernetes version needed + to support Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory + that contains files named "target[suffix][+patchtype].extension". + For example, "kube-apiserver0+merge.yaml" or + just "etcd.json". "target" can be one of "kube-apiserver", + "kube-controller-manager", "kube-scheduler", + "etcd". "patchtype" can be one of "strategic" + "merge" or "json" and they match the patch formats + supported by kubectl. The default "patchtype" + is "strategic". "extension" must be either "json" + or "yaml". "suffix" is an optional string that + can be used to determine which patches are applied + first alpha-numerically. These files can be + written into the target directory via KubeadmConfig.Files + which specifies additional files to be created + on the machine, either with content inline or + by referencing a secret. + type: string + type: object type: object joinConfiguration: description: JoinConfiguration is the kubeadm configuration @@ -2114,6 +2139,31 @@ spec: type: object type: array type: object + patches: + description: Patches contains options related to applying + patches to components deployed by kubeadm during + "kubeadm join". The minimum kubernetes version needed + to support Patches is v1.22 + properties: + directory: + description: Directory is a path to a directory + that contains files named "target[suffix][+patchtype].extension". + For example, "kube-apiserver0+merge.yaml" or + just "etcd.json". "target" can be one of "kube-apiserver", + "kube-controller-manager", "kube-scheduler", + "etcd". "patchtype" can be one of "strategic" + "merge" or "json" and they match the patch formats + supported by kubectl. The default "patchtype" + is "strategic". "extension" must be either "json" + or "yaml". "suffix" is an optional string that + can be used to determine which patches are applied + first alpha-numerically. These files can be + written into the target directory via KubeadmConfig.Files + which specifies additional files to be created + on the machine, either with content inline or + by referencing a secret. + type: string + type: object type: object mounts: description: Mounts specifies a list of mount points to diff --git a/docs/book/src/tasks/kubeadm-bootstrap.md b/docs/book/src/tasks/kubeadm-bootstrap.md index 214143c90448..82f2f3b47b86 100644 --- a/docs/book/src/tasks/kubeadm-bootstrap.md +++ b/docs/book/src/tasks/kubeadm-bootstrap.md @@ -86,6 +86,9 @@ The cloud-init script will be saved into a secret `KubeadmConfig.Status.DataSecr The `KubeadmConfig` object allows full control of Kubeadm init/join operations by exposing raw `InitConfiguration`, `ClusterConfiguration` and `JoinConfiguration` objects. +`InitConfiguration` and `JoinConfiguration` exposes `Patches` field which can be used to specify the patches from a directory, +this support is available from K8s 1.22 version onwards. + CABPK will fill in some values if they are left empty with sensible defaults: | `KubeadmConfig` field | Default |