@@ -32,7 +32,9 @@ import (
3232 "k8s.io/apimachinery/pkg/runtime/serializer"
3333 "k8s.io/utils/ptr"
3434 bootstrapv1beta1 "sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta1"
35+ bootstrapv1 "sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta2"
3536 controlplanev1beta1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta1"
37+ controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2"
3638 clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3739 runtimehooksv1 "sigs.k8s.io/cluster-api/api/runtime/hooks/v1alpha1"
3840 "sigs.k8s.io/cluster-api/exp/runtime/topologymutation"
@@ -85,12 +87,12 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
8587 isControlPlane := holderRef .Kind == "KubeadmControlPlane"
8688
8789 switch obj := obj .(type ) {
88- case * controlplanev1beta1 .KubeadmControlPlaneTemplate :
90+ case * controlplanev1 .KubeadmControlPlaneTemplate :
8991 if err := patchKubeadmControlPlaneTemplate (ctx , obj , variables ); err != nil {
9092 log .Error (err , "Error patching KubeadmControlPlaneTemplate" )
9193 return errors .Wrap (err , "error patching KubeadmControlPlaneTemplate" )
9294 }
93- case * bootstrapv1beta1 .KubeadmConfigTemplate :
95+ case * bootstrapv1 .KubeadmConfigTemplate :
9496 if err := patchKubeadmConfigTemplate (ctx , obj , variables ); err != nil {
9597 log .Error (err , "Error patching KubeadmConfigTemplate" )
9698 return errors .Wrap (err , "error patching KubeadmConfigTemplate" )
@@ -128,7 +130,7 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
128130}
129131
130132// patchKubeadmControlPlaneTemplate patches the KubeadmControlPlaneTemplate.
131- func patchKubeadmControlPlaneTemplate (_ context.Context , tpl * controlplanev1beta1 .KubeadmControlPlaneTemplate , templateVariables map [string ]apiextensionsv1.JSON ) error {
133+ func patchKubeadmControlPlaneTemplate (_ context.Context , tpl * controlplanev1 .KubeadmControlPlaneTemplate , templateVariables map [string ]apiextensionsv1.JSON ) error {
132134 // patch enableSSHIntoNodes
133135 if err := patchUsers (& tpl .Spec .Template .Spec .KubeadmConfigSpec , templateVariables ); err != nil {
134136 return err
@@ -152,11 +154,7 @@ func patchKubeadmControlPlaneTemplate(_ context.Context, tpl *controlplanev1beta
152154 if file .Path == "/etc/kubernetes/manifests/kube-vip.yaml" {
153155 file .Content = kubeVipPodManifestModified
154156 }
155- out := & bootstrapv1beta1.File {}
156- if err := bootstrapv1beta1 .Convert_v1beta2_File_To_v1beta1_File (& file , out , nil ); err != nil {
157- return err
158- }
159- tpl .Spec .Template .Spec .KubeadmConfigSpec .Files = append (tpl .Spec .Template .Spec .KubeadmConfigSpec .Files , * out )
157+ tpl .Spec .Template .Spec .KubeadmConfigSpec .Files = append (tpl .Spec .Template .Spec .KubeadmConfigSpec .Files , file )
160158 }
161159 }
162160
@@ -175,7 +173,7 @@ func patchKubeadmControlPlaneTemplate(_ context.Context, tpl *controlplanev1beta
175173
176174 versionRegex := regexp .MustCompile ("(KUBERNETES_VERSION=.*)" )
177175 tpl .Spec .Template .Spec .KubeadmConfigSpec .Files = append (tpl .Spec .Template .Spec .KubeadmConfigSpec .Files ,
178- bootstrapv1beta1 .File {
176+ bootstrapv1 .File {
179177 Owner : "root:root" ,
180178 Path : "/etc/pre-kubeadm-commands/10-prekubeadmscript.sh" ,
181179 Permissions : "0755" ,
@@ -188,15 +186,15 @@ func patchKubeadmControlPlaneTemplate(_ context.Context, tpl *controlplanev1beta
188186}
189187
190188// KubeadmConfigTemplate patches the KubeadmConfigTemplate.
191- func patchKubeadmConfigTemplate (_ context.Context , tpl * bootstrapv1beta1 .KubeadmConfigTemplate , templateVariables map [string ]apiextensionsv1.JSON ) error {
189+ func patchKubeadmConfigTemplate (_ context.Context , tpl * bootstrapv1 .KubeadmConfigTemplate , templateVariables map [string ]apiextensionsv1.JSON ) error {
192190 // patch enableSSHIntoNodes
193191 if err := patchUsers (& tpl .Spec .Template .Spec , templateVariables ); err != nil {
194192 return err
195193 }
196194
197195 // always add a file so we don't have an empty array.
198196 tpl .Spec .Template .Spec .Files = append (tpl .Spec .Template .Spec .Files ,
199- bootstrapv1beta1 .File {
197+ bootstrapv1 .File {
200198 Owner : "root:root" ,
201199 Path : "/etc/test-extension" ,
202200 Permissions : "0755" ,
@@ -218,7 +216,7 @@ func patchKubeadmConfigTemplate(_ context.Context, tpl *bootstrapv1beta1.Kubeadm
218216
219217 versionRegex := regexp .MustCompile ("(KUBERNETES_VERSION=.*)" )
220218 tpl .Spec .Template .Spec .Files = append (tpl .Spec .Template .Spec .Files ,
221- bootstrapv1beta1 .File {
219+ bootstrapv1 .File {
222220 Owner : "root:root" ,
223221 Path : "/etc/pre-kubeadm-commands/10-prekubeadmscript.sh" ,
224222 Permissions : "0755" ,
@@ -230,7 +228,7 @@ func patchKubeadmConfigTemplate(_ context.Context, tpl *bootstrapv1beta1.Kubeadm
230228 return nil
231229}
232230
233- func patchUsers (kubeadmConfigSpec * bootstrapv1beta1 .KubeadmConfigSpec , templateVariables map [string ]apiextensionsv1.JSON ) error {
231+ func patchUsers (kubeadmConfigSpec * bootstrapv1 .KubeadmConfigSpec , templateVariables map [string ]apiextensionsv1.JSON ) error {
234232 sshKey , err := topologymutation .GetStringVariable (templateVariables , "sshKey" )
235233 if err != nil {
236234 // Skip patch if sshKey variable is not set
@@ -241,7 +239,7 @@ func patchUsers(kubeadmConfigSpec *bootstrapv1beta1.KubeadmConfigSpec, templateV
241239 }
242240
243241 kubeadmConfigSpec .Users = append (kubeadmConfigSpec .Users ,
244- bootstrapv1beta1 .User {
242+ bootstrapv1 .User {
245243 Name : "capv" ,
246244 SSHAuthorizedKeys : []string {sshKey },
247245 Sudo : ptr .To ("ALL=(ALL) NOPASSWD:ALL" ),
0 commit comments