@@ -114,10 +114,7 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
114
114
// the patchKubeadmConfigTemplate func shows how to implement patches only for KubeadmConfigTemplates
115
115
// linked to a specific MachineDeployment class; another option is to check the holderRef value and call
116
116
// this func or more specialized func conditionally.
117
- if err := patchKubeadmConfigTemplate (ctx , obj , variables ); err != nil {
118
- log .Error (err , "Error patching KubeadmConfigTemplate" )
119
- return errors .Wrap (err , "error patching KubeadmConfigTemplate" )
120
- }
117
+ patchKubeadmConfigTemplate (ctx , obj , variables )
121
118
case * infrav1beta1.DockerMachineTemplate , * infrav1.DockerMachineTemplate :
122
119
// NOTE: DockerMachineTemplate could be linked to the ControlPlane or one or more of the existing MachineDeployment class;
123
120
// the patchDockerMachineTemplate func shows how to implement different patches for DockerMachineTemplate
@@ -170,7 +167,49 @@ func patchDockerClusterTemplate(_ context.Context, obj runtime.Object, templateV
170
167
func patchKubeadmControlPlaneTemplate (ctx context.Context , obj runtime.Object , templateVariables map [string ]apiextensionsv1.JSON ) error {
171
168
log := ctrl .LoggerFrom (ctx )
172
169
173
- // 1) Patch RolloutStrategy RollingUpdate MaxSurge with the value from the Cluster Topology variable.
170
+ // 1) Set extraArgs
171
+ switch obj := obj .(type ) {
172
+ case * controlplanev1beta1.KubeadmControlPlaneTemplate :
173
+ if obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration == nil {
174
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration = & bootstrapv1beta1.ClusterConfiguration {}
175
+ }
176
+
177
+ if obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .APIServer .ExtraArgs == nil {
178
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .APIServer .ExtraArgs = map [string ]string {}
179
+ }
180
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .APIServer .ExtraArgs ["v" ] = "2"
181
+
182
+ if obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .ControllerManager .ExtraArgs == nil {
183
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .ControllerManager .ExtraArgs = map [string ]string {}
184
+ }
185
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .ControllerManager .ExtraArgs ["v" ] = "2"
186
+
187
+ if obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .Scheduler .ExtraArgs == nil {
188
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .Scheduler .ExtraArgs = map [string ]string {}
189
+ }
190
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .Scheduler .ExtraArgs ["v" ] = "2"
191
+
192
+ if obj .Spec .Template .Spec .KubeadmConfigSpec .InitConfiguration .NodeRegistration .KubeletExtraArgs == nil {
193
+ obj .Spec .Template .Spec .KubeadmConfigSpec .InitConfiguration .NodeRegistration .KubeletExtraArgs = map [string ]string {}
194
+ }
195
+ obj .Spec .Template .Spec .KubeadmConfigSpec .InitConfiguration .NodeRegistration .KubeletExtraArgs ["v" ] = "2"
196
+
197
+ if obj .Spec .Template .Spec .KubeadmConfigSpec .JoinConfiguration .NodeRegistration .KubeletExtraArgs == nil {
198
+ obj .Spec .Template .Spec .KubeadmConfigSpec .JoinConfiguration .NodeRegistration .KubeletExtraArgs = map [string ]string {}
199
+ }
200
+ obj .Spec .Template .Spec .KubeadmConfigSpec .JoinConfiguration .NodeRegistration .KubeletExtraArgs ["v" ] = "2"
201
+ case * controlplanev1.KubeadmControlPlaneTemplate :
202
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .APIServer .ExtraArgs = append (obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .APIServer .ExtraArgs , bootstrapv1.Arg {Name : "v" , Value : "2" })
203
+
204
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .ControllerManager .ExtraArgs = append (obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .ControllerManager .ExtraArgs , bootstrapv1.Arg {Name : "v" , Value : "2" })
205
+
206
+ obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .Scheduler .ExtraArgs = append (obj .Spec .Template .Spec .KubeadmConfigSpec .ClusterConfiguration .Scheduler .ExtraArgs , bootstrapv1.Arg {Name : "v" , Value : "2" })
207
+
208
+ obj .Spec .Template .Spec .KubeadmConfigSpec .InitConfiguration .NodeRegistration .KubeletExtraArgs = append (obj .Spec .Template .Spec .KubeadmConfigSpec .InitConfiguration .NodeRegistration .KubeletExtraArgs , bootstrapv1.Arg {Name : "v" , Value : "2" })
209
+ obj .Spec .Template .Spec .KubeadmConfigSpec .JoinConfiguration .NodeRegistration .KubeletExtraArgs = append (obj .Spec .Template .Spec .KubeadmConfigSpec .JoinConfiguration .NodeRegistration .KubeletExtraArgs , bootstrapv1.Arg {Name : "v" , Value : "2" })
210
+ }
211
+
212
+ // 2) Patch RolloutStrategy RollingUpdate MaxSurge with the value from the Cluster Topology variable.
174
213
// If this is unset continue as this variable is not required.
175
214
kcpControlPlaneMaxSurge , err := topologymutation .GetStringVariable (templateVariables , "kubeadmControlPlaneMaxSurge" )
176
215
if err != nil {
@@ -206,8 +245,17 @@ func patchKubeadmControlPlaneTemplate(ctx context.Context, obj runtime.Object, t
206
245
}
207
246
208
247
// patchKubeadmConfigTemplate patches the ControlPlaneTemplate.
209
- func patchKubeadmConfigTemplate (_ context.Context , _ runtime.Object , _ map [string ]apiextensionsv1.JSON ) error {
210
- return nil
248
+ func patchKubeadmConfigTemplate (_ context.Context , obj runtime.Object , _ map [string ]apiextensionsv1.JSON ) {
249
+ // 1) Set extraArgs
250
+ switch obj := obj .(type ) {
251
+ case * bootstrapv1beta1.KubeadmConfigTemplate :
252
+ if obj .Spec .Template .Spec .JoinConfiguration .NodeRegistration .KubeletExtraArgs == nil {
253
+ obj .Spec .Template .Spec .JoinConfiguration .NodeRegistration .KubeletExtraArgs = map [string ]string {}
254
+ }
255
+ obj .Spec .Template .Spec .JoinConfiguration .NodeRegistration .KubeletExtraArgs ["v" ] = "2"
256
+ case * bootstrapv1.KubeadmConfigTemplate :
257
+ obj .Spec .Template .Spec .JoinConfiguration .NodeRegistration .KubeletExtraArgs = append (obj .Spec .Template .Spec .InitConfiguration .NodeRegistration .KubeletExtraArgs , bootstrapv1.Arg {Name : "v" , Value : "2" })
258
+ }
211
259
}
212
260
213
261
// patchDockerMachineTemplate patches the DockerMachineTemplate.
0 commit comments