kubernetes系列之十九:配置kubernetes使用kubevirt管理虚拟机

本文档详细介绍了如何配置kubernetes以利用kubevirt管理虚拟机。首先,文章强调了kubevirt在扩展kubernetes以支持虚拟机管理中的作用,并列出了安装前的必要准备,包括安装libvirt和qemu,以及检查节点的虚拟化支持。接着,文章逐步指导读者部署kubevirt,启动VM,并监控其状态。此外,还提供了启动另一个虚拟机的步骤。
摘要由CSDN通过智能技术生成

 

一、前言

kubevirt可以扩展kubernetes的功能以管理虚拟机,其架构见文章

https://github.com/kubevirt/kubevirt/blob/master/docs/architecture.md

在安装之前需要先做如下准备工作:

安装libvirt和qemu软件包

yum -y install qemu-kvm libvirt virt-install bridge-utils

给k8s node打标签

  kubectl label node k8s-01 kubevirt.io=virt-controller
  kubectl label node k8s-02 kubevirt.io=virt-controller
  kubectl label node k8s-03 kubevirt.io=virt-api
  kubectl label node k8s-04 kubevirt.io=virt-api

查看node能力

kubectl get nodes -o yaml
    allocatable:
      cpu: "2"
      devices.kubevirt.io/tun: "110"
      ephemeral-storage: "16415037823"
      hugepages-2Mi: "0"
      memory: 1780264Ki
      pods: "110"
    capacity:
      cpu: "2"
      devices.kubevirt.io/tun: "110"
      ephemeral-storage: 17394Mi
      hugepages-2Mi: "0"
      memory: 1882664Ki
      pods: "110"

查看节点是否支持kvm硬件辅助虚拟化

ls /dev/kvm
ls: cannot access /dev/kvm: No such file or directory

virt-host-validate qemu
  QEMU: Checking for hardware virtualization                                 : FAIL (Only emulated CPUs are available, performance will be significantly limited)
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller mount-point                  : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpu' controller mount-point                     : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuacct' controller mount-point                 : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'cpuset' controller mount-point                  : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'devices' controller mount-point                 : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for cgroup 'blkio' controller mount-point                   : PASS
WARN (Unknown if this platform has IOMMU support)

如不支持,则先生成让kubevirt使用软件虚拟化的配置

kubectl configmap -n kube-system kubevirt-config --from-literal debug.useEmulation=true

支持虚拟化的结果如下:

kubectl get nodes -o yaml

    allocatable:

      cpu: "48"

      devices.kubevirt.io/kvm: "110"

      devices.kubevirt.io/tun: "110"

      ephemeral-storage: "48294789041"

      hugepages-1Gi: "0"

      hugepages-2Mi: "0"

      memory: 263753532Ki

      pods: "110"

    capacity:

      cpu: "48"

      devices.kubevirt.io/kvm: "110"

      devices.kubevirt.io/tun: "110"

      ephemeral-storage: 51175Mi

      hugepages-1Gi: "0"

      hugepages-2Mi: "0"

      memory: 263855932Ki

      pods: "110"

转载自https://blog.csdn.net/cloudvtech

二、安装kubevirt

2.1 部署kubevirt 

export VERSION=v0.8.0
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/$VERSION/kubevirt.yaml

2.2 查看部署结果

virt-api-79c6f4d756-2vwqh                  0/1       Running   0          9s
virt-controller-559c749968-7lwrl           0/1       Running   0          9s
virt-handler-2grjk                         1/1       Running   0          9s
virt-handler-djfbr                         1/1       Running   0          9s
virt-handler-r2pls                         1/1       Running   0          9s
virt-handler-rb948                         1/1       Running   0          9s

2.3 virt-controller logs

level=info timestamp=2018-10-06T14:46:37.788008Z pos=application.go:179 component=virt-controller msg="DataVolume integration disabled"
level=info timestamp=2018-10-06T14:46:37.790568Z pos=application.go:194 component=virt-controller service=http action=listening interface=0.0.0.0 port=8182
level=info timestamp=2018-10-06T14:46:55.398082Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer vmiInformer"
level=info timestamp=2018-10-06T14:46:55.398243Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer kubeVirtPodInformer"
level=info timestamp=2018-10-06T14:46:55.398271Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer vmiPresetInformer"
level=info timestamp=2018-10-06T14:46:55.398300Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer vmInformer"
level=info timestamp=2018-10-06T14:46:55.398322Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer limitrangeInformer"
level=info timestamp=2018-10-06T14:46:55.398339Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer kubeVirtNodeInformer"
level=info timestamp=2018-10-06T14:46:55.398359Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer vmirsInformer"
level=info timestamp=2018-10-06T14:46:55.398372Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer configMapInformer"
level=info timestamp=2018-10-06T14:46:55.398385Z pos=virtinformers.go:117 component=virt-controller service=http msg="STARTING informer fakeDataVolumeInformer"
level=info timestamp=2018-10-06T14:46:55.398430Z pos=vm.go:113 component=virt-controller service=http msg="Starting VirtualMachine controller."
level=info timestamp=2018-10-06T14:46:55.399309Z pos=node.go:104 component=virt-controller service=http msg="Starting node controller."
level=info timestamp=2018-10-06T14:46:55.399360Z pos=vmi.go:165 component=virt-controller service=http msg="Starting vmi controller."
level=info timestamp=2018-10-06T14:46:55.399393Z pos=replicaset.go:111 component=virt-controller service=http msg="Starting VirtualMachineInstanceReplicaSet controller."
level=info timestamp=2018-10-06T14:46:55.399416Z pos=preset.go:74 component=virt-controller service=http msg="Starting Virtual Machine Initializer.”

2.4 virt-api logs

level=info timestamp=2018-10-06T14:46:49.538030Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET url=/ proto=HTTP/2.0 statusCode=404 contentLength=19
level=info timestamp=2018-10-06T14:46:49.550993Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET url=/ proto=HTTP/2.0 statusCode=404 contentLength=19
level=info timestamp=2018-10-06T14:46:51.623461Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET url="/apis/subresources.kubevirt.io/v1alpha2?timeout=32s" proto=HTTP/2.0 statusCode=200 contentLength=136
level=info timestamp=2018-10-06T14:46:52.758037Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET url=/ proto=HTTP/2.0 statusCode=404 contentLength=19
level=info timestamp=2018-10-06T14:46:52.975272Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET url=/openapi/v2 proto=HTTP/2.0 statusCode=404 contentLength=19
level=info timestamp=2018-10-06T14:46:52.976837Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET url=/swagger.json proto=HTTP/2.0 statusCode=404 contentLength=19
level=info timestamp=2018-10-06T14:46:55.124209Z pos=filter.go:46 component=virt-api remoteAddress=10.244.11.128 username=- method=GET
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值