您的位置 首页 教育

kubernetes使用本地磁盘创建虚拟机(四)

1.kubevirt 开启hostDisk支持: 使用yaml文件开启: # kubectl apply -f…

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.21

 4.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直接挂载到宿主机上的性能比较好,比上篇分布式存储效果好点。

本文来自网络,不代表0514资讯网立场,转载请注明出处:https://0514zx.com/info/807.html
0514zx.com

作者: 0514zx.com

优质职场领域创作者
联系我们

联系我们

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部