Skip to content

Commit 5c2df1b

Browse files
Update additionalCategories patch to target controlplane and workers separately (#404)
This allows setting additionalCategories independently for controlplane and worker machine deployments.
1 parent 388836c commit 5c2df1b

File tree

3 files changed

+98
-81
lines changed

3 files changed

+98
-81
lines changed

templates/cluster-template-clusterclass.yaml

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ spec:
197197
controlPlane: true
198198
enabledIf: '{{if .controlPlaneMachineDetails.gpus}}true{{end}}'
199199
name: update-control-plane-machine-template-gpus
200+
- definitions:
201+
- jsonPatches:
202+
- op: add
203+
path: /spec/template/spec/additionalCategories
204+
valueFrom:
205+
variable: controlPlaneMachineDetails.additionalCategories
206+
selector:
207+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
208+
kind: NutanixMachineTemplate
209+
matchResources:
210+
controlPlane: true
211+
enabledIf: '{{if .controlPlaneMachineDetails.additionalCategories}}true{{end}}'
212+
name: update-control-plane-machine-template-additional-categories
200213
- definitions:
201214
- jsonPatches:
202215
- op: add
@@ -252,6 +265,21 @@ spec:
252265
- nutanix-quick-start-worker
253266
enabledIf: '{{if .workerMachineDetails.gpus}}true{{end}}'
254267
name: update-worker-machine-template-gpus
268+
- definitions:
269+
- jsonPatches:
270+
- op: add
271+
path: /spec/template/spec/additionalCategories
272+
valueFrom:
273+
variable: workerMachineDetails.additionalCategories
274+
selector:
275+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
276+
kind: NutanixMachineTemplate
277+
matchResources:
278+
machineDeploymentClass:
279+
names:
280+
- nutanix-quick-start-worker
281+
enabledIf: '{{if .workerMachineDetails.additionalCategories}}true{{end}}'
282+
name: update-worker-machine-template-additional-categories
255283
- definitions:
256284
- jsonPatches:
257285
- op: replace
@@ -300,31 +328,6 @@ spec:
300328
- nutanix-quick-start-worker
301329
enabledIf: '{{if .project}}true{{end}}'
302330
name: add-project
303-
- definitions:
304-
- jsonPatches:
305-
- op: add
306-
path: /spec/template/spec/additionalCategories
307-
valueFrom:
308-
variable: additionalCategories
309-
selector:
310-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
311-
kind: NutanixMachineTemplate
312-
matchResources:
313-
controlPlane: true
314-
- jsonPatches:
315-
- op: add
316-
path: /spec/template/spec/additionalCategories
317-
valueFrom:
318-
variable: additionalCategories
319-
selector:
320-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
321-
kind: NutanixMachineTemplate
322-
matchResources:
323-
machineDeploymentClass:
324-
names:
325-
- nutanix-quick-start-worker
326-
enabledIf: '{{if .additionalCategories}}true{{end}}'
327-
name: add-additional-categories
328331
variables:
329332
- name: sshKey
330333
required: true
@@ -366,6 +369,15 @@ spec:
366369
openAPIV3Schema:
367370
description: Details of the control plane machine deployment.
368371
properties:
372+
additionalCategories:
373+
items:
374+
properties:
375+
key:
376+
type: string
377+
value:
378+
type: string
379+
type: object
380+
type: array
369381
bootType:
370382
type: string
371383
clusterName:
@@ -400,6 +412,15 @@ spec:
400412
openAPIV3Schema:
401413
description: Details of the worker machine deployment.
402414
properties:
415+
additionalCategories:
416+
items:
417+
properties:
418+
key:
419+
type: string
420+
value:
421+
type: string
422+
type: object
423+
type: array
403424
bootType:
404425
type: string
405426
clusterName:
@@ -483,20 +504,6 @@ spec:
483504
uuid:
484505
type: string
485506
type: object
486-
- name: additionalCategories
487-
required: false
488-
schema:
489-
openAPIV3Schema:
490-
description: Additional categories to be added to the machine deployment in
491-
cluster.
492-
items:
493-
properties:
494-
key:
495-
type: string
496-
value:
497-
type: string
498-
type: object
499-
type: array
500507
workers:
501508
machineDeployments:
502509
- class: nutanix-quick-start-worker

templates/clusterclass/clusterclass.yaml

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ spec:
213213
path: /spec/template/spec/gpus
214214
valueFrom:
215215
variable: controlPlaneMachineDetails.gpus
216+
- name: update-control-plane-machine-template-additional-categories
217+
enabledIf: "{{if .controlPlaneMachineDetails.additionalCategories}}true{{end}}"
218+
definitions:
219+
- selector:
220+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
221+
kind: NutanixMachineTemplate
222+
matchResources:
223+
controlPlane: true
224+
jsonPatches:
225+
- op: add
226+
path: /spec/template/spec/additionalCategories
227+
valueFrom:
228+
variable: controlPlaneMachineDetails.additionalCategories
216229
- name: update-worker-machine-template
217230
definitions:
218231
- selector:
@@ -268,6 +281,21 @@ spec:
268281
path: /spec/template/spec/gpus
269282
valueFrom:
270283
variable: workerMachineDetails.gpus
284+
- name: update-worker-machine-template-additional-categories
285+
enabledIf: "{{if .workerMachineDetails.additionalCategories}}true{{end}}"
286+
definitions:
287+
- selector:
288+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
289+
kind: NutanixMachineTemplate
290+
matchResources:
291+
machineDeploymentClass:
292+
names:
293+
- nutanix-quick-start-worker
294+
jsonPatches:
295+
- op: add
296+
path: /spec/template/spec/additionalCategories
297+
valueFrom:
298+
variable: workerMachineDetails.additionalCategories
271299
- name: add-failure-domains
272300
enabledIf: "{{if .failureDomains}}true{{end}}"
273301
definitions:
@@ -316,31 +344,6 @@ spec:
316344
path: /spec/template/spec/project
317345
valueFrom:
318346
variable: project
319-
- name: add-additional-categories
320-
enabledIf: "{{if .additionalCategories}}true{{end}}"
321-
definitions:
322-
- selector:
323-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
324-
kind: NutanixMachineTemplate
325-
matchResources:
326-
controlPlane: true
327-
jsonPatches:
328-
- op: add
329-
path: /spec/template/spec/additionalCategories
330-
valueFrom:
331-
variable: additionalCategories
332-
- selector:
333-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
334-
kind: NutanixMachineTemplate
335-
matchResources:
336-
machineDeploymentClass:
337-
names:
338-
- nutanix-quick-start-worker
339-
jsonPatches:
340-
- op: add
341-
path: /spec/template/spec/additionalCategories
342-
valueFrom:
343-
variable: additionalCategories
344347
variables:
345348
- name: sshKey
346349
required: true
@@ -409,6 +412,15 @@ spec:
409412
type: integer
410413
type:
411414
type: string
415+
additionalCategories:
416+
type: array
417+
items:
418+
type: object
419+
properties:
420+
key:
421+
type: string
422+
value:
423+
type: string
412424
type: object
413425
- name: workerMachineDetails
414426
required: true
@@ -443,6 +455,15 @@ spec:
443455
type: integer
444456
type:
445457
type: string
458+
additionalCategories:
459+
type: array
460+
items:
461+
type: object
462+
properties:
463+
key:
464+
type: string
465+
value:
466+
type: string
446467
type: object
447468
- name: failureDomains
448469
required: false
@@ -499,16 +520,3 @@ spec:
499520
enum:
500521
- name
501522
- uuid
502-
- name: additionalCategories
503-
required: false
504-
schema:
505-
openAPIV3Schema:
506-
description: Additional categories to be added to the machine deployment in cluster.
507-
type: array
508-
items:
509-
type: object
510-
properties:
511-
key:
512-
type: string
513-
value:
514-
type: string

templates/testdata/cluster-with-additional-categories.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ spec:
3434
systemDiskSize: 40Gi
3535
vcpuSockets: 2
3636
vcpusPerSocket: 1
37+
additionalCategories:
38+
- key: fake-category-key
39+
value: fake-category-value
3740
- name: workerMachineDetails
3841
value:
3942
bootType: legacy
@@ -44,10 +47,9 @@ spec:
4447
systemDiskSize: 40Gi
4548
vcpuSockets: 2
4649
vcpusPerSocket: 1
47-
- name: additionalCategories
48-
value:
49-
- key: fake-category-key
50-
value: fake-category-value
50+
additionalCategories:
51+
- key: fake-category-key
52+
value: fake-category-value
5153
version: v1.29.2
5254
workers:
5355
machineDeployments:

0 commit comments

Comments
 (0)