1.kubevirt 开启hostDisk支持:
使用yaml文件开启:
# kubectl apply -f enable-feature-gate.yaml
kubevirt.kubevirt.io/kubevirt configured
apiVersion: kubevirt.io/v1 kind: KubeVirt metadata: name: kubevirt namespace: kubevirt spec: configuration: developerConfiguration: featureGates: - LiveMigration - HostDisk
直接修改kubevirt CR:
# kubectl edit kubevirt kubevirt -n kubevirt
spec:
configuration:
developerConfiguration:
featureGates:
– LiveMigration
– HostDisk直接修改添加:- HostDisk
2.创建镜像:
# virtctl image-upload –uploadproxy-url=https://172.10.212.21 –pvc-name=iso-cen7 –pvc-size=10Gi –insecure –storage-class=rook-ceph-block –access-mode=ReadWriteMany –block-volume –image-path=./CentOS-7-x86_64-DVD-2009.iso
PVC default/iso-cen7 not found
PersistentVolumeClaim default/iso-cen7 created
Waiting for PVC iso-cen7 upload pod to be ready…
Pod now ready
Uploading data to https://172.10.212.214.39 GiB / 4.39 GiB [==========================================================================================================================================================================================================================] 100.00% 20s
Uploading data completed successfully, waiting for processing to complete, you can hit ctrl-c without interrupting the progress
Processing completed successfully
Uploading ./CentOS-7-x86_64-DVD-2009.iso completed successfully
3. 安装虚拟机:
# kubectl apply -f cen7.yaml
virtualmachine.kubevirt.io/cen7.9 created
# virtctl start cen7.9
VM cen7.9 was scheduled to start
# virtctl vnc cen7.9
apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: name: cen7.9 spec: running: false template: metadata: labels: kubevirt.io/domain: cen7.9 spec: domain: cpu: cores: 4 devices: disks: - bootOrder: 1 cdrom: bus: sata name: cdromiso - disk: bus: sata name: harddrive interfaces: - masquerade: {} model: e1000 name: default machine: type: q35 resources: requests: memory: 8G networks: - name: default pod: {} volumes: - name: cdromiso persistentVolumeClaim: claimName: iso-cen7 - name: harddrive hostDisk: capacity: 50Gi path: /data/vms/disk.img type: DiskOrCreate
个人感觉使用hostDisk直接挂载到宿主机上的性能比较好,比上篇分布式存储效果好点。