mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-28 10:18:42 +00:00
120 lines
4.1 KiB
YAML
120 lines
4.1 KiB
YAML
{{- if and .Values.instanceType (not (lookup "instancetype.kubevirt.io/v1beta1" "VirtualMachineClusterInstancetype" "" .Values.instanceType)) }}
|
|
{{- fail (printf "Specified instanceType does not exist in the cluster: %s" .Values.instanceType) }}
|
|
{{- end }}
|
|
{{- if and .Values.instanceProfile (not (lookup "instancetype.kubevirt.io/v1beta1" "VirtualMachineClusterPreference" "" .Values.instanceProfile)) }}
|
|
{{- fail (printf "Specified instanceProfile does not exist in the cluster: %s" .Values.instanceProfile) }}
|
|
{{- end }}
|
|
|
|
apiVersion: kubevirt.io/v1
|
|
kind: VirtualMachine
|
|
metadata:
|
|
name: {{ include "virtual-machine.fullname" . }}
|
|
labels:
|
|
{{- include "virtual-machine.labels" . | nindent 4 }}
|
|
spec:
|
|
running: {{ .Values.running }}
|
|
{{- with .Values.instanceType }}
|
|
instancetype:
|
|
kind: VirtualMachineClusterInstancetype
|
|
name: {{ . }}
|
|
{{- end }}
|
|
{{- with .Values.instanceProfile }}
|
|
preference:
|
|
kind: VirtualMachineClusterPreference
|
|
name: {{ . }}
|
|
{{- end }}
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
kubevirt.io/allow-pod-bridge-network-live-migration: "true"
|
|
labels:
|
|
{{- include "virtual-machine.labels" . | nindent 8 }}
|
|
spec:
|
|
domain:
|
|
{{- if and .Values.resources .Values.resources.cpu .Values.resources.sockets }}
|
|
cpu:
|
|
cores: {{ .Values.resources.cpu }}
|
|
sockets: {{ .Values.resources.sockets }}
|
|
{{- end }}
|
|
{{- if and .Values.resources .Values.resources.memory }}
|
|
resources:
|
|
requests:
|
|
memory: {{ .Values.resources.memory | quote }}
|
|
{{- end }}
|
|
firmware:
|
|
uuid: {{ include "virtual-machine.stableUuid" . }}
|
|
devices:
|
|
{{- if .Values.gpus }}
|
|
gpus:
|
|
{{- range $i, $gpu := .Values.gpus }}
|
|
- name: gpu{{ add $i 1 }}
|
|
deviceName: {{ $gpu.name }}
|
|
{{- end }}
|
|
{{- end }}
|
|
disks:
|
|
{{- range $i, $disk := .Values.disks }}
|
|
- name: disk-{{ $disk.name }}
|
|
{{- $dv := lookup "cdi.kubevirt.io/v1beta1" "DataVolume" $.Release.Namespace (printf "vm-disk-%s" $disk.name) }}
|
|
{{- if $dv }}
|
|
{{- if and (hasKey $dv.metadata.annotations "vm-disk.cozystack.io/optical") (eq (index $dv.metadata.annotations "vm-disk.cozystack.io/optical") "true") }}
|
|
cdrom:
|
|
{{- else }}
|
|
disk:
|
|
{{- end }}
|
|
{{- with $disk.bus }}
|
|
bus: {{ . }}
|
|
{{- end }}
|
|
bootOrder: {{ add $i 1 }}
|
|
{{- else }}
|
|
{{- fail (printf "Specified disk not exists in cluster: %s" .name) }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if or .Values.cloudInit .Values.sshKeys }}
|
|
- name: cloudinitdisk
|
|
disk: {}
|
|
{{- end }}
|
|
interfaces:
|
|
- name: default
|
|
bridge: {}
|
|
{{- if .Values.subnets }}
|
|
{{- range $i, $subnet := .Values.subnets }}
|
|
- name: {{ $subnet.name }}
|
|
bridge: {}
|
|
{{- end }}
|
|
{{- end }}
|
|
machine:
|
|
type: ""
|
|
{{- with .Values.sshKeys }}
|
|
accessCredentials:
|
|
- sshPublicKey:
|
|
source:
|
|
secret:
|
|
secretName: {{ include "virtual-machine.fullname" $ }}-ssh-keys
|
|
propagationMethod:
|
|
# keys will be injected into metadata part of cloud-init disk
|
|
noCloud: {}
|
|
{{- end }}
|
|
terminationGracePeriodSeconds: 30
|
|
volumes:
|
|
{{- range .Values.disks }}
|
|
- name: disk-{{ .name }}
|
|
dataVolume:
|
|
name: vm-disk-{{ .name }}
|
|
{{- end }}
|
|
{{- if or .Values.cloudInit .Values.sshKeys }}
|
|
- name: cloudinitdisk
|
|
cloudInitNoCloud:
|
|
secretRef:
|
|
name: {{ include "virtual-machine.fullname" . }}-cloud-init
|
|
{{- end }}
|
|
networks:
|
|
- name: default
|
|
pod: {}
|
|
{{- if .Values.subnets }}
|
|
{{- range $i, $subnet := .Values.subnets }}
|
|
- name: {{ $subnet.name }}
|
|
multus:
|
|
networkName: {{ $.Release.Namespace }}/{{ $subnet.name }}
|
|
{{- end }}
|
|
{{- end }}
|