https://kubevirt.io/user-guide/storage/containerized_data_importer/
https://github.com/kubevirt/containerized-data-importer
CDI Examples: https://github.com/kubevirt/containerized-data-importer/tree/main/manifests/example
cirros-cloud demo images: https://download.cirros-cloud.net/
CDI(Containerized Data Importer)는 DataVolume을 통해 PVC를 KubeVirt VM용 디스크로 사용할 수 있는 기능을 제공한다. 주요 CDI 사용 사례는 다음과 같다.
클러스터에 CDI, 업로드하려는 VM 디스크, 경로에 virtctl이 설치되어 있어야 한다.
[CDI operator & crd]
export TAG=$(curl -s -w %{redirect_url} <https://github.com/kubevirt/containerized-data-importer/releases/latest>)
export VERSION=$(echo ${TAG##*/})
kubectl create -f <https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-operator.yaml>
kubectl create -f <https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-cr.yaml>
Container Registry에 있는 이미지를 DataVolume으로 저장하고 이를 이용하여 VM으로 만들어보자.
kubectl apply -n cdi -f - <<EOF
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: my-data-volume
spec:
source:
registry:
url: docker://quay.io/containerdisks/ubuntu:22.04
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
EOF