Skip to content

Commit

Permalink
Merge pull request #29 from cloudymax/configmaps
Browse files Browse the repository at this point in the history
Update cpu and clock features
  • Loading branch information
cloudymax authored Nov 24, 2024
2 parents 82cfb3c + 3452f1b commit 597db74
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 111 deletions.
2 changes: 1 addition & 1 deletion charts/kubevirt-vm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: kubevirt-vm
description: Configure a virtual machine for use with Kubevirt

type: application
version: 0.3.7
version: 0.3.8
appVersion: "0.1.0"

maintainers:
Expand Down
16 changes: 11 additions & 5 deletions charts/kubevirt-vm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kubevirt-vm

![Version: 0.3.7](https://img.shields.io/badge/Version-0.3.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
![Version: 0.3.8](https://img.shields.io/badge/Version-0.3.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

Configure a virtual machine for use with Kubevirt

Expand All @@ -16,29 +16,35 @@ Configure a virtual machine for use with Kubevirt
|-----|------|---------|-------------|
| cloudinit | object | `{"enabled":true,"secretName":"friend-scrapmetal-user-data"}` | enable or disable usage of cloud-init |
| diskErrorPolicy | string | `"report"` | controls hypervisor behavior when IO errors occur on disk read or write. Possible values are: 'report', 'ignore', 'enospace' |
| disks | list | `[{"bootorder":2,"bus":"virtio","ephemeral":true,"name":"harddrive","pvc":"debian12","readonly":false,"type":"disk"},{"bootorder":3,"method":"disk","name":"my-secret","readonly":true,"secretName":"test","serialNumber":"CVLY623300HK240D","type":"secret"}]` | List of disks to create for the VM, Will be used to create Datavolumes or PVCs. |
| disks | list | `[{"bootorder":2,"bus":"virtio","ephemeral":true,"name":"harddrive","pvc":"debian12","readonly":false,"type":"disk"}]` | List of disks to create for the VM, Will be used to create Datavolumes or PVCs. |
| service | list | `[{"externalTrafficPolicy":"Cluster","name":"service","ports":[{"name":"ssh","port":22,"protocol":"TCP","targetPort":22},{"name":"vnc","port":5900,"protocol":"TCP","targetPort":5900}],"type":"NodePort"}]` | Service cinfiguration. Used to expose VM to the outside world. Accepts a list of ports to open. |
| virtualMachine.features.acpiEnabled | bool | `true` | |
| virtualMachine.features.autoattachGraphicsDevice | bool | `true` | Attach a basic graphics device for VNC access |
| virtualMachine.features.autoattachPodInterface | bool | `true` | Make pod network interface the default for the VM |
| virtualMachine.features.autoattachSerialConsole | bool | `true` | Attach a serial console device |
| virtualMachine.features.clock | object | `{"enabled":true,"hpet":{"enabled":true,"present":false},"hyperv":false,"kvm":true,"pit":{"enabled":true,"tickPolicy":"delay"},"rtc":{"enabled":true,"tickPolicy":"catchup"}}` | Options for machine clock |
| virtualMachine.features.clock.hpet | object | `{"enabled":true,"present":false}` | High Precision Event Timer |
| virtualMachine.features.clock.pit | object | `{"enabled":true,"tickPolicy":"delay"}` | Programmable interval timer |
| virtualMachine.features.clock.rtc | object | `{"enabled":true,"tickPolicy":"catchup"}` | Real-Time Clock |
| virtualMachine.features.efiEnabled | bool | `true` | Enable EFI bios |
| virtualMachine.features.hyperv | bool | `false` | Set default hyperv settings for windows guests |
| virtualMachine.features.kvmEnabled | bool | `true` | Enable KVM acceleration |
| virtualMachine.features.networkInterfaceMultiqueue | bool | `true` | Enhances network performance by allowing multiple TX and RX queues. |
| virtualMachine.features.secureBoot | bool | `false` | Enable Secure boot (Requires EFI) |
| virtualMachine.features.smmEnabled | bool | `true` | |
| virtualMachine.gpus | list | `[]` | GPUs to pass to guest, requires that the GPUs are pre-configured in the kubevirt custom resource. ignored when instancetype is defined |
| virtualMachine.interfaces | list | `[{"bridge":{},"name":"default"}]` | virtual network interface config options. See: https://kubevirt.io/user-guide/network/interfaces_and_networks/#interfaces |
| virtualMachine.interfaces[0] | object | `{"bridge":{},"name":"default"}` | bridge mode, vms are connected to the network via a linux "bridge". Pod network IP is delegated to vm via DHCPv4. VM must use DHCP for an IP |
| virtualMachine.machine.cpuPassthrough | bool | `true` | Pass all CPU features and capabilities to Guest |
| virtualMachine.machine.architecture | string | `"amd64"` | Arch |
| virtualMachine.machine.cpuModel | string | `"host-passthrough"` | Specify hots-passthrough or a named cpu model https://www.qemu.org/docs/master/system/qemu-cpu-models.html |
| virtualMachine.machine.hyperThreadingEnabled | bool | `false` | Enable the use of Hyperthreading on Intel CPUs. Disable on AMD CPUs. |
| virtualMachine.machine.instancetype | object | `{"kind":"virtualMachineClusterInstancetype","name":"standard-small"}` | Define CPU, RAM, GPU, HostDevice settings for VMs. Uncomment to enable. Overrides: vCores, memory, gpus |
| virtualMachine.machine.instancetype | object | `{"enabled":true,"kind":"virtualMachineClusterInstancetype","name":"standard-small"}` | Define CPU, RAM, GPU, HostDevice settings for VMs. Uncomment to enable. Overrides: vCores, memory, gpus |
| virtualMachine.machine.machineType | string | `"q35"` | QEMU virtual-machine type |
| virtualMachine.machine.memory | string | `"4Gi"` | Amount of RAM to pass to the Guest. Ignored when instancetype is defined |
| 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 | `{}` | |
Expand Down
85 changes: 66 additions & 19 deletions charts/kubevirt-vm/templates/virtualmachine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
namespace: {{ .Values.virtualMachine.namespace }}
name: {{ .Values.virtualMachine.name }}
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 }}
Expand All @@ -23,54 +23,99 @@ spec:
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 -}}
{{ "kvm: {}" | nindent 14 }}
{{- if eq .Values.virtualMachine.features.kvmEnabled true -}}
{{ "kvm: {}" | nindent 10 }}
{{- end }}
{{- if eq .Values.virtualMachine.features.acpiEnabled true -}}
{{ "acpi: {}" | nindent 10 }}
{{- end }}
{{- if .Values.virtualMachine.features.acpiEnabled -}}
{{ "acpi: {}" | nindent 14 }}
{{- if eq .Values.virtualMachine.features.smmEnabled true -}}
{{ "smm:" | nindent 10 -}}
{{ "enabled: true" | nindent 12 }}
{{- end }}
{{- if .Values.virtualMachine.features.smmEnabled -}}
{{ "smm:" | nindent 14 -}}
{{ "enabled: true" | nindent 16 }}
{{- 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 -}}
{{- "threads: 2" | nindent 14 -}}
{{- "threads: 2" | nindent 10 -}}
{{ else }}
{{- "threads: 1" | nindent 14 -}}
{{- "threads: 1" | nindent 10 -}}
{{- end }}
{{- end }}
firmware:
{{- if .Values.virtualMachine.features.efiEnabled }}
bootloader:
efi:
secureBoot: {{ .Values.virtualMachine.features.secureBoot }}
{{ else }}
{{- else }}
bootloader: {}
{{- end }}
devices:
{{- with .Values.virtualMachine.interfaces }}
interfaces:
{{- toYaml . | nindent 14 }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if not .Values.virtualMachine.machine.instancetype }}
{{- if eq .Values.virtualMachine.machine.instancetype.enabled false }}
{{- with .Values.virtualMachine.gpus }}
gpus:
{{- toYaml . | nindent 14 }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
autoattachPodInterface: {{ .Values.virtualMachine.features.autoattachPodInterface }}
autoattachSerialConsole: {{ .Values.virtualMachine.features.autoattachSerialConsole }}
autoattachGraphicsDevice: {{ .Values.virtualMachine.features.autoattachGraphicsDevice }}
networkInterfaceMultiqueue: {{ .Values.virtualMachine.features.networkInterfaceMultiqueue }}
rng: {}
inputs:
- type: tablet
bus: virtio
Expand All @@ -94,20 +139,22 @@ spec:
{{- 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 8 }}
{{- end }}
terminationGracePeriodSeconds: 0
priorityClassName: {{ .Values.virtualMachine.machine.priorityClassName }}
Expand Down
74 changes: 60 additions & 14 deletions charts/kubevirt-vm/templates/virtualmachinepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -69,15 +112,15 @@ spec:
bootloader:
efi:
secureBoot: {{ .Values.virtualMachine.features.secureBoot }}
{{ else }}
{{- else }}
bootloader: {}
{{- end }}
devices:
{{- with .Values.virtualMachine.interfaces }}
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 }}
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
Loading

0 comments on commit 597db74

Please sign in to comment.