[root@liabio kubevirt]# kubectl delete -f kubevirt-cr.yaml
kubevirt.kubevirt.io "kubevirt" deleted
[root@liabio kubevirt]# kubectl delete -f kubevirt-operator.yaml
namespace "kubevirt" deleted
customresourcedefinition.apiextensions.k8s.io "kubevirts.kubevirt.io" deleted
priorityclass.scheduling.k8s.io "kubevirt-cluster-critical" deleted
clusterrole.rbac.authorization.k8s.io "kubevirt.io:operator" deleted
serviceaccount "kubevirt-operator" deleted
role.rbac.authorization.k8s.io "kubevirt-operator" deleted
rolebinding.rbac.authorization.k8s.io "kubevirt-operator-rolebinding" deleted
clusterrole.rbac.authorization.k8s.io "kubevirt-operator" deleted
clusterrolebinding.rbac.authorization.k8s.io "kubevirt-operator" deleted
deployment.apps "virt-operator" deleted
[root@liabio kubevirt]# kubectl get cm -n kubevirt
No resources found in kubevirt namespace.
[root@liabio kubevirt]# kubectl create namespace kubevirt
namespace/kubevirt created
[root@liabio kubevirt]# kubectl create configmap -n kubevirt kubevirt-config \
> --from-literal debug.useEmulation=true
configmap/kubevirt-config created
[root@liabio kubevirt]# export VERSION=v0.26.0
[root@liabio kubevirt]# kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
namespace/kubevirt configured
customresourcedefinition.apiextensions.k8s.io/kubevirts.kubevirt.io created
clusterrole.rbac.authorization.k8s.io/kubevirt.io:operator created
serviceaccount/kubevirt-operator created
clusterrole.rbac.authorization.k8s.io/kubevirt-operator created
clusterrolebinding.rbac.authorization.k8s.io/kubevirt-operator created
deployment.apps/virt-operator created
[root@liabio kubevirt]# kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
kubevirt.kubevirt.io/kubevirt created
[root@liabio kubevirt]# kubectl -n kubevirt wait kv kubevirt --for condition=Available
error: timed out waiting for the condition on kubevirts/kubevirt
[root@liabio kubevirt]#
[root@liabio kubevirt]# kubectl -n kubevirt wait kv kubevirt --for condition=Available
kubevirt.kubevirt.io/kubevirt condition met
[root@liabio kubevirt]# kubectl get cm -n kubevirt
NAME DATA AGE
kubevirt-config 1 77s
kubevirt-install-strategy-ww5wq 1 51s
[root@liabio kubevirt]# kubectl get pod -owide -n kubevirt
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
virt-api-f94f8b959-6gcpd 1/1 Running 0 63s 192.168.155.65 liabio <none> <none>
virt-api-f94f8b959-c5hq9 1/1 Running 0 63s 192.168.155.78 liabio <none> <none>
virt-controller-64766f7cbf-dl8tg 1/1 Running 0 41s 192.168.155.80 liabio <none> <none>
virt-controller-64766f7cbf-rbqgv 1/1 Running 0 41s 192.168.155.82 liabio <none> <none>
virt-handler-97d68 1/1 Running 0 41s 192.168.155.83 liabio <none> <none>
virt-operator-754549685-glq58 1/1 Running 0 78s 192.168.155.77 liabio <none> <none>
virt-operator-754549685-krb8l 1/1 Running 0 78s 192.168.155.76 liabio <none> <none>
[root@liabio kubevirt]# ll
-rw-r--r-- 1 root root 875 Sep 18 14:35 fedora-cloud-container-disk-demo-vm.yaml
[root@liabio kubevirt]# kubectl apply -f fedora-cloud-container-disk-demo-vm.yaml
virtualmachineinstance.kubevirt.io/testvmi-nocloud created
[root@liabio kubevirt]#
[root@liabio kubevirt]# kubectl get pod -owide
virt-launcher-testvmi-nocloud-jcxfk 0/2 ContainerCreating 0 31s <none> liabio <none> <none>
[root@liabio kubevirt]# mkdir kubevirt-v0.26.0
[root@liabio kubevirt]# ll
total 593860
-rw-r--r-- 1 root root 875 Sep 18 14:35 fedora-cloud-container-disk-demo-vm.yaml
drwxr-xr-x 2 root root 4096 Sep 22 07:49 kubevirt-v0.26.0
[root@liabio kubevirt]# cd kubevirt-v0.26.0/
[root@liabio kubevirt-v0.26.0]# ll
total 0
[root@liabio kubevirt-v0.26.0]# wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
--2020-09-22 07:49:46-- https://github.com/kubevirt/kubevirt/releases/download/v0.26.0/kubevirt-operator.yaml
Resolving github.com (github.com)... 140.82.113.4
Connecting to github.com (github.com)|140.82.113.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/76686583/9578db80-4992-11ea-8952-141a50d6b2f1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200921%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200921T234947Z&X-Amz-Expires=300&X-Amz-Signature=575abdcc36585ab7afaf0241964533cbfcf0e8b1c5133a0609b629c1f7c5dcbd&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=76686583&response-content-disposition=attachment%3B%20filename%3Dkubevirt-operator.yaml&response-content-type=application%2Foctet-stream [following]
--2020-09-22 07:49:47-- https://github-production-release-asset-2e65be.s3.amazonaws.com/76686583/9578db80-4992-11ea-8952-141a50d6b2f1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200921%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200921T234947Z&X-Amz-Expires=300&X-Amz-Signature=575abdcc36585ab7afaf0241964533cbfcf0e8b1c5133a0609b629c1f7c5dcbd&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=76686583&response-content-disposition=attachment%3B%20filename%3Dkubevirt-operator.yaml&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.89.156
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.89.156|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10575 (10K) [application/octet-stream]
Saving to: ‘kubevirt-operator.yaml’
kubevirt-operator.yaml 100%[===================================================================>] 10.33K --.-KB/s in 0s
2020-09-22 07:49:48 (132 MB/s) - ‘kubevirt-operator.yaml’ saved [10575/10575]
[root@liabio kubevirt-v0.26.0]# wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
--2020-09-22 07:49:57-- https://github.com/kubevirt/kubevirt/releases/download/v0.26.0/kubevirt-cr.yaml
Resolving github.com (github.com)... 140.82.113.4
Connecting to github.com (github.com)|140.82.113.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/76686583/96117200-4992-11ea-8636-e8b316d4520b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200921%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200921T234957Z&X-Amz-Expires=300&X-Amz-Signature=6701fb8720d29859c780375c145c81d6d8c151b965a83db47554d8c575610e1f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=76686583&response-content-disposition=attachment%3B%20filename%3Dkubevirt-cr.yaml&response-content-type=application%2Foctet-stream [following]
--2020-09-22 07:49:58-- https://github-production-release-asset-2e65be.s3.amazonaws.com/76686583/96117200-4992-11ea-8636-e8b316d4520b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200921%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200921T234957Z&X-Amz-Expires=300&X-Amz-Signature=6701fb8720d29859c780375c145c81d6d8c151b965a83db47554d8c575610e1f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=76686583&response-content-disposition=attachment%3B%20filename%3Dkubevirt-cr.yaml&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.28.4
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.28.4|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 139 [application/octet-stream]
Saving to: ‘kubevirt-cr.yaml’
kubevirt-cr.yaml 100%[===================================================================>] 139 --.-KB/s in 0s
2020-09-22 07:49:59 (4.69 MB/s) - ‘kubevirt-cr.yaml’ saved [139/139]
[root@liabio kubevirt-v0.26.0]# ll
total 16
-rw-r--r-- 1 root root 139 Feb 7 2020 kubevirt-cr.yaml
-rw-r--r-- 1 root root 10575 Feb 7 2020 kubevirt-operator.yaml
[root@liabio kubevirt]# kubectl get pod -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
virt-launcher-testvmi-nocloud-jcxfk 2/2 Running 0 3m32s 192.168.155.69 liabio <none> <none>
[root@liabio kubevirt]# kubectl logs -f virt-launcher-testvmi-nocloud-jcxfk compute
{"component":"virt-launcher","level":"info","msg":"Collected all requested hook sidecar sockets","pos":"manager.go:68","timestamp":"2020-09-21T23:49:38.229909Z"}
{"component":"virt-launcher","level":"info","msg":"Sorted all collected sidecar sockets per hook point based on their priority and name: map[]","pos":"manager.go:71","timestamp":"2020-09-21T23:49:38.230020Z"}
{"component":"virt-launcher","level":"info","msg":"Watchdog file created at /var/run/kubevirt/watchdog-files/default_testvmi-nocloud","pos":"virt-launcher.go:143","timestamp":"2020-09-21T23:49:38.234428Z"}
{"component":"virt-launcher","level":"info","msg":"Connecting to libvirt daemon: qemu:///system","pos":"libvirt.go:355","timestamp":"2020-09-21T23:49:38.237415Z"}
{"component":"virt-launcher","level":"info","msg":"Connecting to libvirt daemon failed: virError(Code=38, Domain=7, Message='Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory')","pos":"libvirt.go:363","timestamp":"2020-09-21T23:49:38.238846Z"}
{"component":"virt-launcher","level":"info","msg":"libvirt version: 5.6.0, package: 7.fc31 (Unknown, 2019-11-22-21:16:59, )","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.286000Z"}
{"component":"virt-launcher","level":"info","msg":"hostname: testvmi-nocloud","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.286000Z"}
{"component":"virt-launcher","level":"error","msg":"internal error: Unable to get DBus system bus connection: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory","pos":"virDBusGetSystemBus:108","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.286000Z"}
{"component":"virt-launcher","level":"error","msg":"internal error: Child process (/usr/sbin/dmidecode -q -t 0,1,2,3,4,17) unexpected exit status 1: /dev/mem: No such file or directory","pos":"virCommandWait:2792","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.290000Z"}
{"component":"virt-launcher","level":"error","msg":"Unable to open /dev/kvm: No such file or directory","pos":"virHostCPUGetMSRFromKVM:1282","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.319000Z"}
{"component":"virt-launcher","level":"error","msg":"Unable to open /dev/kvm: No such file or directory","pos":"virHostCPUGetMSRFromKVM:1282","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.627000Z"}
{"component":"virt-launcher","level":"info","msg":"Connected to libvirt daemon","pos":"libvirt.go:371","timestamp":"2020-09-21T23:49:38.740524Z"}
{"component":"virt-launcher","level":"info","msg":"Registered libvirt event notify callback","pos":"client.go:294","timestamp":"2020-09-21T23:49:38.897166Z"}
{"component":"virt-launcher","level":"info","msg":"Marked as ready","pos":"virt-launcher.go:73","timestamp":"2020-09-21T23:49:38.897611Z"}
{"component":"virt-launcher","level":"info","msg":"Hardware emulation device '/dev/kvm' not present. Using software emulation.","pos":"converter.go:636","timestamp":"2020-09-21T23:49:43.903550Z"}
{"component":"virt-launcher","level":"info","msg":"In-kernel virtio-net device emulation '/dev/vhost-net' not present. Falling back to QEMU userland emulation.","pos":"converter.go:649","timestamp":"2020-09-21T23:49:43.912767Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Executing PreStartHook on VMI pod environment","name":"testvmi-nocloud","namespace":"default","pos":"manager.go:775","timestamp":"2020-09-21T23:49:43.913207Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Starting PreCloudInitIso hook","name":"testvmi-nocloud","namespace":"default","pos":"manager.go:794","timestamp":"2020-09-21T23:49:43.913262Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","level":"info","msg":"generated nocloud iso file /var/run/kubevirt-ephemeral-disks/cloud-init-data/default/testvmi-nocloud/noCloud.iso","pos":"cloud-init.go:449","timestamp":"2020-09-21T23:49:43.959303Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"masquerade pod interface: VIF: { Name: eth0, IP: 10.0.2.2, Mask: ffffff00, MAC: 02:00:00:74:59:a8, Gateway: 10.0.2.1, MTU: 1440}","name":"testvmi-nocloud","namespace":"default","pos":"podinterface.go:446","timestamp":"2020-09-21T23:49:44.068139Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","level":"info","msg":"Found nameservers in /etc/resolv.conf: \n\n\u0000\n","pos":"converter.go:1508","timestamp":"2020-09-21T23:49:44.084632Z"}
{"component":"virt-launcher","level":"info","msg":"Found search domains in /etc/resolv.conf: default.svc.cluster.local svc.cluster.local cluster.local","pos":"converter.go:1509","timestamp":"2020-09-21T23:49:44.084689Z"}
{"component":"virt-launcher","level":"info","msg":"Starting SingleClientDHCPServer","pos":"dhcp.go:64","timestamp":"2020-09-21T23:49:44.085226Z"}
{"component":"virt-launcher","level":"info","msg":"Driver cache mode for /var/run/kubevirt-ephemeral-disks/disk-data/containerdisk/disk.qcow2 set to none","pos":"converter.go:175","timestamp":"2020-09-21T23:49:44.117679Z"}
{"component":"virt-launcher","level":"info","msg":"Driver cache mode for /var/run/libvirt/empty-disks/emptydisk.qcow2 set to none","pos":"converter.go:175","timestamp":"2020-09-21T23:49:44.117758Z"}
{"component":"virt-launcher","level":"info","msg":"Driver cache mode for /var/run/kubevirt-ephemeral-disks/cloud-init-data/default/testvmi-nocloud/noCloud.iso set to none","pos":"converter.go:175","timestamp":"2020-09-21T23:49:44.117791Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Domain defined.","name":"testvmi-nocloud","namespace":"default","pos":"manager.go:1054","timestamp":"2020-09-21T23:49:44.159901Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","level":"info","msg":"DomainLifecycle event 0 with reason 0 received","pos":"client.go:259","timestamp":"2020-09-21T23:49:44.160250Z"}
{"component":"virt-launcher","level":"error","msg":"internal error: Unable to get DBus system bus connection: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory","pos":"virDBusGetSystemBus:108","subcomponent":"libvirt","thread":"25","timestamp":"2020-09-21T23:49:44.166000Z"}
{"component":"virt-launcher","level":"error","msg":"At least one cgroup controller is required: No such device or address","pos":"virCgroupDetect:419","subcomponent":"libvirt","thread":"25","timestamp":"2020-09-21T23:49:44.215000Z"}
{"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Paused(3):StartingUp(11)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.226818Z"}
{"component":"virt-launcher","level":"info","msg":"Detected domain with UUID 0883b53b-f09e-461e-a017-9217a94ee42a","pos":"virt-launcher.go:234","timestamp":"2020-09-21T23:49:44.235109Z"}
{"component":"virt-launcher","level":"info","msg":"Monitoring loop: rate 1s start timeout 5m0s","pos":"monitor.go:237","timestamp":"2020-09-21T23:49:44.235160Z"}
{"component":"virt-launcher","level":"info","msg":"GuestAgentLifecycle event state 2 with reason 1 received","pos":"client.go:277","timestamp":"2020-09-21T23:49:44.480060Z"}
{"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Paused(3):StartingUp(11)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.481544Z"}
{"component":"virt-launcher","level":"info","msg":"DomainLifecycle event 4 with reason 0 received","pos":"client.go:259","timestamp":"2020-09-21T23:49:44.670951Z"}
{"component":"virt-launcher","level":"info","msg":"DomainLifecycle event 2 with reason 0 received","pos":"client.go:259","timestamp":"2020-09-21T23:49:44.672248Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Domain started.","name":"testvmi-nocloud","namespace":"default","pos":"manager.go:1085","timestamp":"2020-09-21T23:49:44.673229Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Synced vmi","name":"testvmi-nocloud","namespace":"default","pos":"server.go:167","timestamp":"2020-09-21T23:49:44.676161Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Running(1):Unknown(1)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.677291Z"}
{"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Running(1):Unknown(1)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.684449Z"}
{"component":"virt-launcher","level":"info","msg":"Hardware emulation device '/dev/kvm' not present. Using software emulation.","pos":"converter.go:636","timestamp":"2020-09-21T23:49:44.852824Z"}
{"component":"virt-launcher","level":"info","msg":"In-kernel virtio-net device emulation '/dev/vhost-net' not present. Falling back to QEMU userland emulation.","pos":"converter.go:649","timestamp":"2020-09-21T23:49:44.852892Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Synced vmi","name":"testvmi-nocloud","namespace":"default","pos":"server.go:167","timestamp":"2020-09-21T23:49:44.856521Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","level":"info","msg":"Hardware emulation device '/dev/kvm' not present. Using software emulation.","pos":"converter.go:636","timestamp":"2020-09-21T23:49:44.902030Z"}
{"component":"virt-launcher","level":"info","msg":"In-kernel virtio-net device emulation '/dev/vhost-net' not present. Falling back to QEMU userland emulation.","pos":"converter.go:649","timestamp":"2020-09-21T23:49:44.902086Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Synced vmi","name":"testvmi-nocloud","namespace":"default","pos":"server.go:167","timestamp":"2020-09-21T23:49:44.907227Z","uid":"8c8b3e88-249f-447d-adbc-b9746fadb4a4"}
{"component":"virt-launcher","level":"info","msg":"Found PID for 0883b53b-f09e-461e-a017-9217a94ee42a: 99","pos":"monitor.go:206","timestamp":"2020-09-21T23:49:45.239757Z"}
[root@liabio kubevirt]#
[root@liabio kubevirt]#
[root@liabio kubevirt]#
[root@liabio kubevirt]# kubectl get pod -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
miniprog-56d87d84cf-4p7xl 1/1 Running 0 50d 192.168.155.87 liabio <none> <none>
mysql-79bd6fcfd-chxr4 1/1 Running 1 50d 192.168.155.88 liabio <none> <none>
redis-0 1/1 Running 0 50d 192.168.155.89 liabio <none> <none>
solo-9bf6f7764-knb4r 1/1 Running 0 50d 10.0.9.52 liabio <none> <none>
virt-launcher-testvmi-nocloud-jcxfk 2/2 Running 0 6m32s 192.168.155.69 liabio <none> <none>
[root@liabio kubevirt]#
[root@liabio kubevirt]# kubectl get pod -owide
^C
[root@liabio kubevirt]# kubectl get pod -owide -n kubevirt
参考
官方部署文档