Commit 4bbfcf8
authored
fix(patches): Ensure resulting NutanixMachineTemplate patches are clean (#1236)
These changes ensure the resulting NutanixMachineTemplate patches also
reflect
the XOR between failureDomains and cluster/subnets.
**How has this been tested?**
Tested in conjunction with
#1233
in
#1226
* Run `make dev.run-on-kind` and see default NutanixMachineTemplates
when management cluster is created and observe no placeholder cluster
and subnet fields
```yaml
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nutanix-quick-start-cp-nmt
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
name: nutanix-quick-start
spec:
template:
spec:
bootType: legacy
image:
name: ""
type: name
memorySize: 4Gi
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nutanix-quick-start-md-nmt
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
name: nutanix-quick-start
spec:
template:
spec:
bootType: legacy
image:
name: ""
type: name
memorySize: 4Gi
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
```
* Create a cluster without failure domains with a machine deployment
with cluster and subnet set
```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
...
name: nkp-sid-caren-no-fd
spec:
...
topology:
class: nutanix-quick-start
controlPlane:
metadata: {}
replicas: 3
variables:
- name: clusterConfig
value:
...
controlPlane:
nutanix:
machineDetails:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 4Gi
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
cluster:
type: name
name: ncn-dev-sandbox
subnets:
- type: name
name: vlan173
...
- name: workerConfig
value:
nutanix:
machineDetails:
bootType: uefi
cluster:
name: ncn-dev-sandbox
type: name
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 4Gi
subnets:
- name: vlan173
type: name
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
version: 1.33.1
workers:
machineDeployments:
- class: default-worker
metadata:
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "1"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "1"
name: md-0
variables:
overrides:
- name: workerConfig
value:
nutanix:
machineDetails:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 8Gi
cluster:
type: name
name: ncn-dev-sandbox
subnets:
- type: name
name: vlan173
systemDiskSize: 80Gi
vcpuSockets: 8
vcpusPerSocket: 1
- class: default-worker
metadata:
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "1"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "1"
name: md-1
variables:
overrides:
- name: workerConfig
value:
nutanix:
machineDetails:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 8Gi
cluster:
type: uuid
uuid: 00061f7f-44f7-19dc-3be1-7cc25586ee44
subnets:
- type: name
name: vlan173
systemDiskSize: 80Gi
vcpuSockets: 8
vcpusPerSocket: 1
```
Observe the generated NutanixMachineTemplate has cluster and subnets set
correctly
```yaml
apiVersion: v1
items:
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nkp-sid-caren-no-fd-7np7m
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: nkp-sid-caren-no-fd
spec:
template:
spec:
bootType: uefi
cluster:
name: ncn-dev-sandbox
type: name
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 4Gi
subnet:
- name: vlan173
type: name
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nkp-sid-caren-no-fd-md-0-qnr58
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: nkp-sid-caren-no-fd
spec:
template:
spec:
bootType: uefi
cluster:
name: ncn-dev-sandbox
type: name
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 8Gi
subnet:
- name: vlan173
type: name
systemDiskSize: 80Gi
vcpuSockets: 8
vcpusPerSocket: 1
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nkp-sid-caren-no-fd-md-1-59tlq
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: nkp-sid-caren-no-fd
spec:
template:
spec:
bootType: uefi
cluster:
type: uuid
uuid: 00061f7f-44f7-19dc-3be1-7cc25586ee44
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 8Gi
subnet:
- name: vlan173
type: name
systemDiskSize: 80Gi
vcpuSockets: 8
vcpusPerSocket: 1
```
* Create a cluster with control plane and machine deployment on failure
domains
```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
cluster.x-k8s.io/cluster-name: nkp-sid-caren
cluster.x-k8s.io/provider: nutanix
name: nkp-sid-caren
spec:
...
topology:
class: nutanix-quick-start
controlPlane:
metadata: {}
replicas: 3
variables:
- name: clusterConfig
value:
...
controlPlane:
nutanix:
failureDomains:
- fd-1
- fd-2
- fd-3
machineDetails:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 4Gi
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
...
- name: workerConfig
value:
nutanix:
machineDetails:
bootType: uefi
cluster:
name: ncn-dev-sandbox
type: name
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 4Gi
subnets:
- name: vlan173
type: name
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
version: 1.33.1
workers:
machineDeployments:
- class: default-worker
failureDomain: fd-1
metadata:
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "1"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "1"
name: md-0
variables:
overrides:
- name: workerConfig
value:
nutanix:
machineDetails:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 8Gi
systemDiskSize: 80Gi
vcpuSockets: 8
vcpusPerSocket: 1
```
Observe the generated NutanixMachineTemplate does not have cluster and
subnet set
```yaml
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nkp-sid-caren-kp4nc
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: nkp-sid-caren
spec:
template:
spec:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 4Gi
systemDiskSize: 40Gi
vcpuSockets: 2
vcpusPerSocket: 1
- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: NutanixMachineTemplate
metadata:
...
name: nkp-sid-caren-md-0-bfm6v
namespace: default
ownerReferences:
- apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: nkp-sid-caren
spec:
template:
spec:
bootType: uefi
imageLookup:
baseOS: rocky-9.6
format: nkp-{{.BaseOS}}-release-{{.K8sVersion}}-*
memorySize: 8Gi
systemDiskSize: 80Gi
vcpuSockets: 8
vcpusPerSocket: 1
```1 parent 1f08425 commit 4bbfcf8
File tree
10 files changed
+65
-53
lines changed- api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1
- charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses
- common/pkg/capi/clustertopology/handlers/mutation
- hack
- examples
- overlays/clusterclasses/nutanix
- patches/nutanix
- third-party/capx
- pkg/handlers/nutanix/mutation
- controlplanefailuredomains
- machinedetails
10 files changed
+65
-53
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
Lines changed: 0 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | 307 | | |
311 | 308 | | |
312 | 309 | | |
313 | 310 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | 311 | | |
318 | 312 | | |
319 | 313 | | |
| |||
328 | 322 | | |
329 | 323 | | |
330 | 324 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | 325 | | |
335 | 326 | | |
336 | 327 | | |
337 | 328 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | 329 | | |
342 | 330 | | |
343 | 331 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
103 | 115 | | |
| 116 | + | |
104 | 117 | | |
105 | 118 | | |
| 119 | + | |
| 120 | + | |
106 | 121 | | |
107 | 122 | | |
| 123 | + | |
108 | 124 | | |
109 | 125 | | |
110 | 126 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 102 | | |
108 | 103 | | |
109 | 104 | | |
| |||
122 | 117 | | |
123 | 118 | | |
124 | 119 | | |
125 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
| |||
Lines changed: 28 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
94 | 93 | | |
95 | | - | |
96 | 94 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
100 | 101 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 102 | | |
108 | 103 | | |
109 | 104 | | |
| |||
125 | 120 | | |
126 | 121 | | |
127 | 122 | | |
128 | | - | |
129 | | - | |
130 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
170 | 168 | | |
171 | 169 | | |
172 | 170 | | |
| |||
189 | 187 | | |
190 | 188 | | |
191 | 189 | | |
192 | | - | |
193 | | - | |
194 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
195 | 198 | | |
196 | 199 | | |
197 | 200 | | |
| |||
0 commit comments