Helm chart for testing.

This commit is contained in:
Michael Lipp 2023-06-10 15:26:54 +02:00
parent bd8b8c56c0
commit f1f9d89d47
9 changed files with 282 additions and 0 deletions

View file

@ -0,0 +1,115 @@
apiVersion: v1
kind: ConfigMap
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
data:
config.yaml: |
"/Runner":
# The directory used to store data files. Defaults to (depending on
# values available):
# * $XDG_DATA_HOME/vmrunner/${vm.name}
# * $HOME/.local/share/vmrunner/${vm.name}
# * ./${vm.name}
"dataDir": "/var/local/vm-data"
# The directory used to store runtime files. Defaults to (depending on
# values available):
# * $XDG_RUNTIME_DIR/vmrunner/${vm.name}
# * /tmp/${USER}/vmrunner/${vm.name}
# * /tmp/vmrunner/${vm.name}
# "runtimeDir": "$XDG_RUNTIME_DIR/vmrunner/${vm.name}"
# The template to use. Resolved relative to /usr/share/vmrunner/templates.
# "template": "Standard-VM-latest.ftl.yaml"
# The template is copied to the data diretory when the VM starts for
# the first time. Subsequent starts use the copy unless this option is set.
"updateTemplate": true
# Define the VM (required)
"vm":
# The VM's name (required)
"name": "{{ .Release.Name }}"
# The machine's uuid. If none is specified, a uuid is generated
# and stored in the data directory. If the uuid is important
# (e.g. because licenses depend on it) it is recommaned to specify
# it here explicitly or to carefully backup the data directory.
{{- if hasKey .Values.vm "machineUuid" }}
"uuid": "{{ .Values.vm.machineUuid }}"
{{- end }}
# Whether to provide a software TPM (defaults to false)
"useTpm": {{ .Values.vm.useTpm }}
# How to boot (see https://github.com/mnlipp/VM-Operator/blob/main/org.jdrupes.vmoperator.runner.qemu/resources/org/jdrupes/vmoperator/runner/qemu/defaults.yaml):
# * bios
# * uefi[-4m]
# * secure[-4m]
"firmware": "{{ .Values.vm.firmware }}"
# When terminating, a graceful powerdown is attempted. If it
# doesn't succeed within the given timeout (seconds) SIGTERM
# is sent to Qemu.
"powerdownTimeout": "{{ .Values.vm.powerdownTimeout }}"
# RAM settings
"maximumRam": "{{ .Values.vm.maximumMemory }}"
# "currentRam": "1G"
# CPU settings
"cpuModel": "{{ .Values.vm.cpuModel }}"
# Setting maximumCpus to 1 omits the "-smp" options. The defaults (0)
# cause the corresponding property to be omitted from the "-smp" option.
# If currentCpus is greater than maximumCpus, the latter is adjusted.
"maximumCpus": {{ .Values.vm.maximumCpus }}
"currentCpus": {{ .Values.vm.currentCpus }}
# "cpuSockets": 0
# "diesPerSocket": 0
# "coresPerSocket": 0
# "threadsPerCore": 0
# "accelertor": "kvm"
# RTC settings.
"rtcBase": "{{ .Values.vm.rtcBase }}"
# "rtcClock": "rt"
# Network settings
# Supported types are "tap" and "user" (for debugging). Type "user"
# supports only the property "net".
# "network":
# - "type": "tap"
# "bridge": "br0"
# "device": "virtio-net"
# "mac": (undefined)
"network":
{{- range $index, $network := .Values.vm.networks }}
{{- if hasKey $network "bridge" }}
- "type": "tap"
{{- if hasKey $network.bridge "name" }}
"bridge": "{{ $network.bridge.name }}"
{{- end }}
{{- if hasKey $network.bridge "mac" }}
"mac": "{{ $network.bridge.mac }}"
{{- end }}
{{- end }}
{{- end }}
# There are no default drives. The supported types are "ide-cd"
# and "raw". All types support a "bootindex" property.
# Type "raw" can have a property "file" (if backed by a file on
# the host) or a property "device" (if backed by a device).
# "drives":
# - "type": "ide-cd"
# "bootindex": (undefined)
# "file": (undefined)
"drives":
{{- range $index, $disk := .Values.vm.disks }}
- "type": "raw"
"device": "/dev/disk-{{ $index }}"
{{- end }}
"spice":
"port": {{ .Values.vm.spicePort }}
# "usbRedirects": 2

View file

@ -0,0 +1,60 @@
kind: Pod
apiVersion: v1
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
labels:
app: qemu-vm
vm: {{ .Release.Name }}
spec:
containers:
- name: {{ .Release.Name }}
image: {{ .Values.image.repository }}/{{ .Values.image.path }}:{{ .Values.image.version }}
resources: {}
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
# Not needed because pod is priviledged:
# - mountPath: /dev/kvm
# name: dev-kvm
# - mountPath: /dev/net/tun
# name: dev-tun
# - mountPath: /sys/fs/cgroup
# name: cgroup
- mountPath: /etc/opt/vmrunner
name: config
- mountPath: /var/local/vm-data
name: vm-data
volumeDevices:
{{- range $index, $disk := .Values.vm.disks }}
- devicePath: /dev/disk-{{ $index }}
name: disk-{{ $index }}
{{- end }}
securityContext:
privileged: true
volumes:
# Not needed because pod is priviledged:
# - name: dev-kvm
# hostPath:
# path: /dev/kvm
# type: CharDevice
# - hostPath:
# path: /dev/net/tun
# type: CharDevice
# name: dev-tun
# - name: cgroup
# hostPath:
# path: /sys/fs/cgroup
- name: config
configMap:
name: {{ $.Release.Name }}
- name: vm-data
hostPath:
path: /var/local/vmrunner/{{ .Release.Name }}
{{- range $index, $disk := .Values.vm.disks }}
- name: disk-{{ $index }}
persistentVolumeClaim:
claimName: {{ $.Release.Name }}-pvc-{{ $index }}
{{- end }}
hostNetwork: true
terminationGracePeriodSeconds: 60
restartPolicy: Never

View file

@ -0,0 +1,28 @@
{{- range $index, $disk := .Values.vm.disks }}
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ $.Release.Name }}-pv-{{ $index }}
spec:
capacity:
storage: {{ .size }}
volumeMode: Block
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: ""
claimRef:
name: {{ $.Release.Name }}-pvc-{{ $index }}
namespace: {{ $.Release.Namespace }}
local:
path: {{ .device }}
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- {{ required "Valid .Values.vm.host entry required" $.Values.vm.host }}
{{- end }}

View file

@ -0,0 +1,17 @@
{{- range $index, $disk := .Values.vm.disks }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
namespace: {{ $.Release.Namespace }}
name: {{ $.Release.Name }}-pvc-{{ $index }}
spec:
accessModes:
- ReadWriteOnce
storageClassName: ""
volumeMode: Block
resources:
requests:
storage: {{ .size }}
{{- end }}