apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  labels:
    kubevirt.io/os: linux
  name: {{ .Values.name }}
spec:
  running: true
  template:
    metadata:
      creationTimestamp: null
      labels:
        kubevirt.io/domain: debian
        app: {{ .Values.name }}
    spec:
      domain:
        cpu:
          cores: {{ .Values.cpuCores }}
        resources:
          limits:
            memory: {{ .Values.memory }}
        devices:
          interfaces:
            - name: default
              # masquerade: {}
              bridge: {}
              ports:
              {{- range .Values.ports }}
              - name: {{ .name }}
                port: {{ .value }}
                protocol: {{ .protocol }}
              {{- end }}
          disks:
            - name: disk0
              disk:
                bus: virtio
            - name: cloudinitdisk
              disk:
                bus: virtio
                readonly: true
      networks:
        - name: default
          pod: {}
      volumes:
        - name: disk0
          persistentVolumeClaim:
            claimName: dv-{{ .Values.name }}
        - name: cloudinitdisk
          cloudInitNoCloud:
            secretRef:
              name: {{ .Values.name }}-user-data
            networkDataSecretRef:
              name: {{ .Values.name }}-network-data
