kubevirt部署虚拟机
创建pvc,并且上传windows镜像,IP地址可以通过kubectl -n cdi get svc -l cdi.kubevirt.io=cdi-uploadproxy 来查看
virtctl image-upload \ --image-path='Win10_21H2_Chinese(Simplified)_x64.iso' \ --storage-class cephfs \ --pvc-name=iso-win10 \ --pvc-size=7G \ --uploadproxy-url=https://<uploadproxy-url-IP> \ --insecure \ --wait-secs=240
开启hostDisk支持(但是我这里老报错所以没用这种方式)
apiVersion: kubevirt.io/v1 kind: KubeVirt metadata: name: kubevirt namespace: kubevirt spec: configuration: developerConfiguration: featureGates: - LiveMigration - HostDisk
windows虚拟机
apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: win10 spec: running: true template: metadata: labels: kubevirt.io/domain: win10 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: 16G networks: - name: default pod: {} volumes: - name: cdromiso persistentVolumeClaim: claimName: win10 - name: harddrive persistentVolumeClaim: claimName: win10-data
启动虚拟机实例
virtctl start win10
vnc登录安装系统
virtctl vnc win10
想远程访问需要开启端口转发
kubectl virt expose vm win10 --name win10-rdp --port 3389 --target-port 3389 --type NodePort