Skip to content

Instantly share code, notes, and snippets.

@phosae
Created October 12, 2023 08:45
Show Gist options
  • Save phosae/410e4dea1606759e2bf6b448dba1678a to your computer and use it in GitHub Desktop.
Save phosae/410e4dea1606759e2bf6b448dba1678a to your computer and use it in GitHub Desktop.
Dockerfile for KubeVirt VM
FROM busybox:1.35.0
ADD centos.qcow2 /disk/ # centos.qcow2 or centos.img
RUN chmod 766 disk
@phosae
Copy link
Author

phosae commented Oct 12, 2023

build and push to Docker Hub as xxx/centos:7.9

consume it as DataVolume

apiVersion: kubevirt.io/v1
kind: VirtualMachine
spec:
  template:
    spec:
      domain:
        devices:
          disks:
          - name: osdisk
            disk:
              bus: virtio
      volumes:
      - dataVolume:
          name: mytestvm-osdv
---
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
  name: mytestvm-osdv
spec:
  pvc:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 200Gi
  source:
    registry:
      pullMethod: node
      url: docker://xxx/centos:7.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment