File tree Expand file tree Collapse file tree 3 files changed +67
-3
lines changed
docs/content/customization/nutanix
pkg/handlers/nutanix/mutation/machinedetails Expand file tree Collapse file tree 3 files changed +67
-3
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ type NutanixNodeSpec struct {
1313 MachineDetails NutanixMachineDetails `json:"machineDetails"`
1414}
1515
16+ // +kubebuilder:validation:XValidation:rule="has(self.image) != has(self.imageLookup)",message="Either 'image' or 'imageLookup' must be set, but not both"
1617type NutanixMachineDetails struct {
1718 // vcpusPerSocket is the number of vCPUs per socket of the VM
1819 // +kubebuilder:validation:Required
@@ -28,8 +29,14 @@ type NutanixMachineDetails struct {
2829
2930 // image identifies the image uploaded to Prism Central (PC). The identifier
3031 // (uuid or name) can be obtained from the console or API.
31- // +kubebuilder:validation:Required
32- Image capxv1.NutanixResourceIdentifier `json:"image"`
32+ // +kubebuilder:validation:Optional
33+ // +optional
34+ Image * capxv1.NutanixResourceIdentifier `json:"image,omitempty"`
35+
36+ // imageLookup is a container that holds how to look up vm images for the cluster.
37+ // +kubebuilder:validation:Optional
38+ // +optional
39+ ImageLookup * capxv1.NutanixImageLookup `json:"imageLookup,omitempty"`
3340
3441 // cluster identifies the Prism Element in which the machine will be created.
3542 // The identifier (uuid or name) can be obtained from the console or API.
Original file line number Diff line number Diff line change @@ -111,6 +111,59 @@ spec:
111111 vcpusPerSocket: 1
112112` ` `
113113
114+ # ## (Optional) Use Image template
115+
116+ ` ` ` yaml
117+ apiVersion: cluster.x-k8s.io/v1beta1
118+ kind: Cluster
119+ metadata:
120+ name: <NAME>
121+ spec:
122+ topology:
123+ variables:
124+ - name: clusterConfig
125+ value:
126+ controlPlane:
127+ nutanix:
128+ machineDetails:
129+ bootType: legacy
130+ cluster:
131+ name: pe-cluster-name
132+ type: name
133+ imageLookup:
134+ baseOS: "rockylinux-9"
135+ format: {{.BaseOS}}-kube-v{{.K8sVersion}}.*
136+ ` ` `
137+
138+ Applying this configuration will result in the following value being set :
139+
140+ - control-plane `NutanixMachineTemplate` :
141+
142+ ` ` ` yaml
143+ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
144+ kind: NutanixMachineTemplate
145+ metadata:
146+ name: nutanix-quick-start-cp-nmt
147+ spec:
148+ template:
149+ spec:
150+ bootType: legacy
151+ cluster:
152+ name: pe-cluster-name
153+ type: name
154+ imageLookup:
155+ baseOS: "rockylinux-9"
156+ format: {{.BaseOS}}-kube-v{{.K8sVersion}}.*
157+ memorySize: 4Gi
158+ providerID: nutanix://vm-uuid
159+ subnet:
160+ - name: subnet-name
161+ type: name
162+ systemDiskSize: 40Gi
163+ vcpuSockets: 2
164+ vcpusPerSocket: 1
165+ ` ` `
166+
114167# ## (Optional) Set Additional Categories for Control Plane and Worker nodes
115168
116169` ` ` yaml
Original file line number Diff line number Diff line change @@ -94,7 +94,11 @@ func (h *nutanixMachineDetailsPatchHandler) Mutate(
9494
9595 spec .BootType = nutanixMachineDetailsVar .BootType
9696 spec .Cluster = nutanixMachineDetailsVar .Cluster
97- spec .Image = nutanixMachineDetailsVar .Image
97+ if nutanixMachineDetailsVar .Image != nil {
98+ spec .Image = nutanixMachineDetailsVar .Image
99+ } else if nutanixMachineDetailsVar .ImageLookup != nil {
100+ spec .ImageLookup = nutanixMachineDetailsVar .ImageLookup
101+ }
98102
99103 spec .VCPUSockets = nutanixMachineDetailsVar .VCPUSockets
100104 spec .VCPUsPerSocket = nutanixMachineDetailsVar .VCPUsPerSocket
You can’t perform that action at this time.
0 commit comments