[vm-instance] Fix review issues: validation, DRY, and regenerate CRD
Add fail validation when both 'networks' and 'subnets' are set to prevent silent data loss during migration. Compute $networks variable once at template top level to eliminate DRY violation. Regenerate CRD via make generate instead of manual editing. Assisted-By: Claude AI Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
This commit is contained in:
parent
c27807952a
commit
a56ef30df6
3 changed files with 36 additions and 4 deletions
|
|
@ -47,8 +47,10 @@ virtctl ssh <user>@<vm>
|
|||
| `disks` | List of disks to attach. | `[]object` | `[]` |
|
||||
| `disks[i].name` | Disk name. | `string` | `""` |
|
||||
| `disks[i].bus` | Disk bus type (e.g. "sata"). | `string` | `""` |
|
||||
| `subnets` | Additional subnets | `[]object` | `[]` |
|
||||
| `subnets[i].name` | Subnet name | `string` | `""` |
|
||||
| `networks` | Networks to attach the VM to. | `[]object` | `[]` |
|
||||
| `networks[i].name` | Network attachment name. | `string` | `""` |
|
||||
| `subnets` | Deprecated: use networks instead. | `[]object` | `[]` |
|
||||
| `subnets[i].name` | Network attachment name. | `string` | `""` |
|
||||
| `gpus` | List of GPUs to attach (NVIDIA driver requires at least 4 GiB RAM). | `[]object` | `[]` |
|
||||
| `gpus[i].name` | The name of the GPU resource to attach. | `string` | `""` |
|
||||
| `cpuModel` | Model specifies the CPU model inside the VMI. List of available models https://github.com/libvirt/libvirt/tree/master/src/cpu_map | `string` | `""` |
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
{{- if and (not .Values.instanceType) (not (and .Values.resources .Values.resources.cpu .Values.resources.sockets .Values.resources.memory)) }}
|
||||
{{- fail "Either instanceType or resources (cpu, sockets, memory) must be specified" }}
|
||||
{{- end }}
|
||||
{{- if and .Values.networks .Values.subnets }}
|
||||
{{- fail "Both 'networks' and 'subnets' are set. Use only 'networks'; 'subnets' is deprecated." }}
|
||||
{{- end }}
|
||||
{{- $networks := .Values.networks | default .Values.subnets }}
|
||||
|
||||
apiVersion: kubevirt.io/v1
|
||||
kind: VirtualMachine
|
||||
|
|
@ -86,7 +90,6 @@ spec:
|
|||
interfaces:
|
||||
- name: default
|
||||
bridge: {}
|
||||
{{- $networks := .Values.networks | default .Values.subnets }}
|
||||
{{- range $i, $net := $networks }}
|
||||
- name: {{ $net.name }}
|
||||
bridge: {}
|
||||
|
|
@ -122,7 +125,6 @@ spec:
|
|||
networks:
|
||||
- name: default
|
||||
pod: {}
|
||||
{{- $networks := .Values.networks | default .Values.subnets }}
|
||||
{{- range $i, $net := $networks }}
|
||||
- name: {{ $net.name }}
|
||||
multus:
|
||||
|
|
|
|||
|
|
@ -150,6 +150,20 @@
|
|||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"networks": {
|
||||
"description": "Networks to attach the VM to.",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "Network attachment name.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"description": "Resource configuration for the virtual machine.",
|
||||
"type": "object",
|
||||
|
|
@ -204,6 +218,20 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"subnets": {
|
||||
"description": "Deprecated: use networks instead.",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "Network attachment name.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cloudInit": {
|
||||
"description": "Cloud-init user data.",
|
||||
"type": "string",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue