From 3452f1bb57962355f21226fa3964b1599f8837ab Mon Sep 17 00:00:00 2001 From: cloudymax Date: Sun, 24 Nov 2024 17:18:57 +0100 Subject: [PATCH] sync vm and pool options --- charts/kubevirt-vm/README.md | 2 +- .../kubevirt-vm/templates/virtualmachine.yaml | 6 +- .../templates/virtualmachinepool.yaml | 74 +++++++++++++++---- charts/kubevirt-vm/values.yaml | 2 +- charts/kubevirt-vm/win-values.yaml | 18 ++++- 5 files changed, 81 insertions(+), 21 deletions(-) diff --git a/charts/kubevirt-vm/README.md b/charts/kubevirt-vm/README.md index cbcc8a4..e931208 100644 --- a/charts/kubevirt-vm/README.md +++ b/charts/kubevirt-vm/README.md @@ -44,7 +44,7 @@ Configure a virtual machine for use with Kubevirt | virtualMachine.machine.pinCores | bool | `false` | Pin QEMU process to specific physical cores Requires `--cpu-manager-policy` enabled in kubelet | | virtualMachine.machine.priorityClassName | string | `"vm-standard"` | If a Pod cannot be scheduled, lower priorityClass Pods will be evicted | | virtualMachine.machine.vCores | int | `4` | Number of Virtual cores to pass to the Guest ignored when instancetype is defined | -| virtualMachine.name | string | `"scrapmetal"` | name of the virtualMachine or virtualMachinePool object | +| virtualMachine.name | string | `"scrapmetal2"` | name of the virtualMachine or virtualMachinePool object | | virtualMachine.namespace | string | `"kubevirt"` | namespace to deploy | | virtualMachine.networks[0].name | string | `"default"` | | | virtualMachine.networks[0].pod | object | `{}` | | diff --git a/charts/kubevirt-vm/templates/virtualmachine.yaml b/charts/kubevirt-vm/templates/virtualmachine.yaml index 12fa425..08b8e3d 100644 --- a/charts/kubevirt-vm/templates/virtualmachine.yaml +++ b/charts/kubevirt-vm/templates/virtualmachine.yaml @@ -31,15 +31,15 @@ spec: clock: utc: {} timer: - {{ if eq .Values.virtualMachine.features.clock.hpet.enabled true }} + {{- if eq .Values.virtualMachine.features.clock.hpet.enabled true }} hpet: present: {{ .Values.virtualMachine.features.clock.hpet.present }} {{- end }} - {{ if eq .Values.virtualMachine.features.clock.pit.enabled true }} + {{- if eq .Values.virtualMachine.features.clock.pit.enabled true }} pit: tickPolicy: {{ .Values.virtualMachine.features.clock.pit.tickPolicy }} {{- end }} - {{ if eq .Values.virtualMachine.features.clock.rtc.enabled true }} + {{- if eq .Values.virtualMachine.features.clock.rtc.enabled true }} rtc: tickPolicy: {{ .Values.virtualMachine.features.clock.rtc.tickPolicy }} {{- end }} diff --git a/charts/kubevirt-vm/templates/virtualmachinepool.yaml b/charts/kubevirt-vm/templates/virtualmachinepool.yaml index 4258fde..7a570ad 100644 --- a/charts/kubevirt-vm/templates/virtualmachinepool.yaml +++ b/charts/kubevirt-vm/templates/virtualmachinepool.yaml @@ -24,38 +24,81 @@ spec: kubevirt-service: {{ .Values.virtualMachine.name }} kubevirt-manager.io/managed: "true" spec: - {{- if .Values.virtualMachine.machine.instancetype }} + {{- if eq .Values.virtualMachine.machine.instancetype.enabled true }} instancetype: name: {{ .Values.virtualMachine.machine.instancetype.name }} kind: {{ .Values.virtualMachine.machine.instancetype.kind }} {{- end }} - running: true + runStrategy: {{ .Values.virtualMachine.runStrategy }} template: metadata: creationTimestamp: null labels: - kubevirt.io/vmpool: {{ .Values.virtualMachine.name }} kubevirt.io/domain: {{ .Values.virtualMachine.name }} kubevirt-service: {{ .Values.virtualMachine.name }} kubevirt-manager.io/managed: "true" spec: + architecture: {{ .Values.virtualMachine.machine.architecture }} domain: + machine: + type: {{ .Values.virtualMachine.machine.machineType }} + {{- if eq .Values.virtualMachine.features.clock.enabled true }} + clock: + utc: {} + timer: + {{- if eq .Values.virtualMachine.features.clock.hpet.enabled true }} + hpet: + present: {{ .Values.virtualMachine.features.clock.hpet.present }} + {{- end }} + {{- if eq .Values.virtualMachine.features.clock.pit.enabled true }} + pit: + tickPolicy: {{ .Values.virtualMachine.features.clock.pit.tickPolicy }} + {{- end }} + {{- if eq .Values.virtualMachine.features.clock.rtc.enabled true }} + rtc: + tickPolicy: {{ .Values.virtualMachine.features.clock.rtc.tickPolicy }} + {{- end }} + {{- if eq .Values.virtualMachine.features.clock.hyperv true }} + hyperv: {} + {{- end }} + {{- if eq .Values.virtualMachine.features.clock.kvm true }} + kvm: {} + {{- end }} + {{- end }} features: - {{- if .Values.virtualMachine.features.kvmEnabled -}} + {{- if eq .Values.virtualMachine.features.kvmEnabled true -}} {{ "kvm: {}" | nindent 14 }} {{- end }} - {{- if .Values.virtualMachine.features.acpiEnabled -}} + {{- if eq .Values.virtualMachine.features.acpiEnabled true -}} {{ "acpi: {}" | nindent 14 }} {{- end }} - {{- if .Values.virtualMachine.features.smmEnabled -}} + {{- if eq .Values.virtualMachine.features.smmEnabled true -}} {{ "smm:" | nindent 14 -}} {{ "enabled: true" | nindent 16 }} {{- end }} + {{- if eq .Values.virtualMachine.features.hyperv true }} + hyperv: + relaxed: {} + vapic: {} + vpindex: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + frequencies: {} + reenlightenment: {} + ipi: {} + runtime: {} + reset: {} + {{- end }} cpu: - {{- if .Values.virtualMachine.machine.cpuPassthrough -}} - {{ "model: host-passthrough" | nindent 14 }} + {{- if eq .Values.virtualMachine.machine.pinCores true }} + dedicatedCpuPlacement: true {{- end }} - {{- if not .Values.virtualMachine.machine.instancetype }} + model: {{ .Values.virtualMachine.machine.cpuModel }} + {{- if eq .Values.virtualMachine.machine.instancetype.enabled false }} sockets: 1 cores: {{ .Values.virtualMachine.machine.vCores -}} {{- if .Values.virtualMachine.machine.hyperThreadingEnabled -}} @@ -69,7 +112,7 @@ spec: bootloader: efi: secureBoot: {{ .Values.virtualMachine.features.secureBoot }} - {{ else }} + {{- else }} bootloader: {} {{- end }} devices: @@ -77,7 +120,7 @@ spec: interfaces: {{- toYaml . | nindent 14 }} {{- end }} - {{- if not .Values.virtualMachine.machine.instancetype }} + {{- if eq .Values.virtualMachine.machine.instancetype.enabled false }} {{- with .Values.virtualMachine.gpus }} gpus: {{- toYaml . | nindent 14 }} @@ -87,6 +130,7 @@ spec: autoattachSerialConsole: {{ .Values.virtualMachine.features.autoattachSerialConsole }} autoattachGraphicsDevice: {{ .Values.virtualMachine.features.autoattachGraphicsDevice }} networkInterfaceMultiqueue: {{ .Values.virtualMachine.features.networkInterfaceMultiqueue }} + rng: {} inputs: - type: tablet bus: virtio @@ -107,23 +151,25 @@ spec: {{- end }} {{- end }} {{- end }} - {{- if $props.configMap }} + {{- if eq $props.type "configmap" }} - name: {{ $props.name }} serial: {{ $props.serialNumber }} + cdrom: + bus: sata {{- end }} {{- if eq $props.type "secret" }} - name: {{ $props.name }} serial: {{ $props.serialNumber }} {{- end }} {{- end }} - {{- if not .Values.virtualMachine.machine.instancetype }} + {{- if eq .Values.virtualMachine.machine.instancetype.enabled false }} resources: limits: memory: {{ .Values.virtualMachine.machine.memory }} {{- end }} {{- with .Values.virtualMachine.networks }} networks: - {{- toYaml . | nindent 10 }} + {{- toYaml . | nindent 12 }} {{- end }} terminationGracePeriodSeconds: 0 priorityClassName: {{ .Values.virtualMachine.machine.priorityClassName }} diff --git a/charts/kubevirt-vm/values.yaml b/charts/kubevirt-vm/values.yaml index c23dda6..3197b32 100644 --- a/charts/kubevirt-vm/values.yaml +++ b/charts/kubevirt-vm/values.yaml @@ -2,7 +2,7 @@ # Virtual Machine settings virtualMachine: # -- name of the virtualMachine or virtualMachinePool object - name: scrapmetal + name: scrapmetal2 # -- namespace to deploy namespace: kubevirt # -- One of 'Always' `RerunOnFailure` `Manual` `Halted` `Once` diff --git a/charts/kubevirt-vm/win-values.yaml b/charts/kubevirt-vm/win-values.yaml index f16a57d..f824cf6 100644 --- a/charts/kubevirt-vm/win-values.yaml +++ b/charts/kubevirt-vm/win-values.yaml @@ -14,13 +14,27 @@ virtualMachine: autoattachPodInterface: true autoattachSerialConsole: true autoattachGraphicsDevice: true + hyperv: true + clock: + enabled: true + hpet: + enabled: true + present: false + pit: + enabled: true + tickPolicy: delay + rtc: + enabled: true + tickPolicy: catchup + kvm: false + hyperv: true machine: instancetype: enabled: false priorityClassName: vm-standard machineType: "q35" - cpuPassthrough: true + cpuModel: host-passthrough vCores: 4 pinCores: false hyperThreadingEnabled: true @@ -31,7 +45,7 @@ virtualMachine: interfaces: - name: default bridge: {} - model: e1000e + model: e1000 networks: - name: default