Skip to content

Commit

Permalink
Update additionalCategories patch to target controlplane and workers …
Browse files Browse the repository at this point in the history
…separately (#404)

This allows setting additionalCategories independently for controlplane and
worker machine deployments.
  • Loading branch information
thunderboltsid authored Apr 4, 2024
1 parent 388836c commit 5c2df1b
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 81 deletions.
85 changes: 46 additions & 39 deletions templates/cluster-template-clusterclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,19 @@ spec:
controlPlane: true
enabledIf: '{{if .controlPlaneMachineDetails.gpus}}true{{end}}'
name: update-control-plane-machine-template-gpus
- definitions:
- jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: controlPlaneMachineDetails.additionalCategories
selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
controlPlane: true
enabledIf: '{{if .controlPlaneMachineDetails.additionalCategories}}true{{end}}'
name: update-control-plane-machine-template-additional-categories
- definitions:
- jsonPatches:
- op: add
Expand Down Expand Up @@ -252,6 +265,21 @@ spec:
- nutanix-quick-start-worker
enabledIf: '{{if .workerMachineDetails.gpus}}true{{end}}'
name: update-worker-machine-template-gpus
- definitions:
- jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: workerMachineDetails.additionalCategories
selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
machineDeploymentClass:
names:
- nutanix-quick-start-worker
enabledIf: '{{if .workerMachineDetails.additionalCategories}}true{{end}}'
name: update-worker-machine-template-additional-categories
- definitions:
- jsonPatches:
- op: replace
Expand Down Expand Up @@ -300,31 +328,6 @@ spec:
- nutanix-quick-start-worker
enabledIf: '{{if .project}}true{{end}}'
name: add-project
- definitions:
- jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: additionalCategories
selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
controlPlane: true
- jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: additionalCategories
selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
machineDeploymentClass:
names:
- nutanix-quick-start-worker
enabledIf: '{{if .additionalCategories}}true{{end}}'
name: add-additional-categories
variables:
- name: sshKey
required: true
Expand Down Expand Up @@ -366,6 +369,15 @@ spec:
openAPIV3Schema:
description: Details of the control plane machine deployment.
properties:
additionalCategories:
items:
properties:
key:
type: string
value:
type: string
type: object
type: array
bootType:
type: string
clusterName:
Expand Down Expand Up @@ -400,6 +412,15 @@ spec:
openAPIV3Schema:
description: Details of the worker machine deployment.
properties:
additionalCategories:
items:
properties:
key:
type: string
value:
type: string
type: object
type: array
bootType:
type: string
clusterName:
Expand Down Expand Up @@ -483,20 +504,6 @@ spec:
uuid:
type: string
type: object
- name: additionalCategories
required: false
schema:
openAPIV3Schema:
description: Additional categories to be added to the machine deployment in
cluster.
items:
properties:
key:
type: string
value:
type: string
type: object
type: array
workers:
machineDeployments:
- class: nutanix-quick-start-worker
Expand Down
84 changes: 46 additions & 38 deletions templates/clusterclass/clusterclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ spec:
path: /spec/template/spec/gpus
valueFrom:
variable: controlPlaneMachineDetails.gpus
- name: update-control-plane-machine-template-additional-categories
enabledIf: "{{if .controlPlaneMachineDetails.additionalCategories}}true{{end}}"
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
controlPlane: true
jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: controlPlaneMachineDetails.additionalCategories
- name: update-worker-machine-template
definitions:
- selector:
Expand Down Expand Up @@ -268,6 +281,21 @@ spec:
path: /spec/template/spec/gpus
valueFrom:
variable: workerMachineDetails.gpus
- name: update-worker-machine-template-additional-categories
enabledIf: "{{if .workerMachineDetails.additionalCategories}}true{{end}}"
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
machineDeploymentClass:
names:
- nutanix-quick-start-worker
jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: workerMachineDetails.additionalCategories
- name: add-failure-domains
enabledIf: "{{if .failureDomains}}true{{end}}"
definitions:
Expand Down Expand Up @@ -316,31 +344,6 @@ spec:
path: /spec/template/spec/project
valueFrom:
variable: project
- name: add-additional-categories
enabledIf: "{{if .additionalCategories}}true{{end}}"
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
controlPlane: true
jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: additionalCategories
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
matchResources:
machineDeploymentClass:
names:
- nutanix-quick-start-worker
jsonPatches:
- op: add
path: /spec/template/spec/additionalCategories
valueFrom:
variable: additionalCategories
variables:
- name: sshKey
required: true
Expand Down Expand Up @@ -409,6 +412,15 @@ spec:
type: integer
type:
type: string
additionalCategories:
type: array
items:
type: object
properties:
key:
type: string
value:
type: string
type: object
- name: workerMachineDetails
required: true
Expand Down Expand Up @@ -443,6 +455,15 @@ spec:
type: integer
type:
type: string
additionalCategories:
type: array
items:
type: object
properties:
key:
type: string
value:
type: string
type: object
- name: failureDomains
required: false
Expand Down Expand Up @@ -499,16 +520,3 @@ spec:
enum:
- name
- uuid
- name: additionalCategories
required: false
schema:
openAPIV3Schema:
description: Additional categories to be added to the machine deployment in cluster.
type: array
items:
type: object
properties:
key:
type: string
value:
type: string
10 changes: 6 additions & 4 deletions templates/testdata/cluster-with-additional-categories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ spec:
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
additionalCategories:
- key: fake-category-key
value: fake-category-value
- name: workerMachineDetails
value:
bootType: legacy
Expand All @@ -44,10 +47,9 @@ spec:
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
- name: additionalCategories
value:
- key: fake-category-key
value: fake-category-value
additionalCategories:
- key: fake-category-key
value: fake-category-value
version: v1.29.2
workers:
machineDeployments:
Expand Down

0 comments on commit 5c2df1b

Please sign in to comment.