docs/doc/source/kube-virt/persistent-storage-for-vms-8ddc8fa611aa.rst
Elisamara Aoki Goncalves 1f91cd1ee0 Update documentation for Kubevirt
Add Usage Examples sections.
Create KubeVirt Architecture section.
Fix minor editorial issues.
Fix grammar and formatting issues.

Story: 2010931
Task: 50286

Change-Id: I6118d0af848d07f3764eeae5ea8467864c65fceb
Signed-off-by: Elisamara Aoki Goncalves <elisamaraaoki.goncalves@windriver.com>
2024-09-04 22:08:20 +00:00

2.4 KiB

Persistent Storage for VMs

Allows connecting a PersistentVolumeClaim to a disk.

Use a PersistentVolumeClaim when the VirtualMachineInstance disk needs to persist after the terminates. This allows for the 's data to remain persistent between restarts.

A PersistentVolume can be in filesystem or block mode.

Below is a simple example which attaches a PersistentVolumeClaim as a disk to a VM:

apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
  name: testvmi-pvc
spec:
  domain:
    resources:
      requests:
        memory: 64M
    devices:
      disks:
      - name: mypvcdisk
        lun: {}
  volumes:
    - name: mypvcdisk
      persistentVolumeClaim:
        claimName: mypvc

Upload VM Image to CDI

You can upload/import a VM image to , creating a on system, so you can use the to boot or create the .

  1. Get the upload proxy Server IP.

    kubectl -n cdi get svc |grep cdi-uploadproxy
    cdi-uploadproxy          ClusterIP   10.111.132.43    <none>        443/TCP    85m
  2. Use virtctl client upload the image to .

    virtctl image-upload --pvc-name=cirros-vm-disk-test-2 --pvc-size=500Mi --image-path=/home/sysadmin/kubevirt-valid/cirros-0.5.1-x86_64-disk.img --uploadproxy-url=https://<uploadproxy-svc-ip> --insecure

Note

Now you can use pvc cirros-vm-disk-test-2 in specs.

apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
  name: testvmi-pvc-1
spec:
  domain:
    resources:
      requests:
        memory: 64M
devices:
  disks:
  - name: mypvcdisk
    lun: {}
  volumes:
  - name: mypvcdisk
    persistentVolumeClaim:
      claimName: cirros-vm-disk-test-2 

If you want to upload an image located outside the cluster, the cluster admin should expose the upload proxy to the outside, for example with NodePort.

For more details see set-up-cdi-proxy-ad165d884417.