1. [root@liabio kubevirt]# kubectl delete -f kubevirt-cr.yaml
  2. kubevirt.kubevirt.io "kubevirt" deleted
  3. [root@liabio kubevirt]# kubectl delete -f kubevirt-operator.yaml
  4. namespace "kubevirt" deleted
  5. customresourcedefinition.apiextensions.k8s.io "kubevirts.kubevirt.io" deleted
  6. priorityclass.scheduling.k8s.io "kubevirt-cluster-critical" deleted
  7. clusterrole.rbac.authorization.k8s.io "kubevirt.io:operator" deleted
  8. serviceaccount "kubevirt-operator" deleted
  9. role.rbac.authorization.k8s.io "kubevirt-operator" deleted
  10. rolebinding.rbac.authorization.k8s.io "kubevirt-operator-rolebinding" deleted
  11. clusterrole.rbac.authorization.k8s.io "kubevirt-operator" deleted
  12. clusterrolebinding.rbac.authorization.k8s.io "kubevirt-operator" deleted
  13. deployment.apps "virt-operator" deleted
  14. [root@liabio kubevirt]# kubectl get cm -n kubevirt
  15. No resources found in kubevirt namespace.
  16. [root@liabio kubevirt]# kubectl create namespace kubevirt
  17. namespace/kubevirt created
  18. [root@liabio kubevirt]# kubectl create configmap -n kubevirt kubevirt-config \
  19. > --from-literal debug.useEmulation=true
  20. configmap/kubevirt-config created
  21. [root@liabio kubevirt]# export VERSION=v0.26.0
  22. [root@liabio kubevirt]# kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
  23. Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
  24. namespace/kubevirt configured
  25. customresourcedefinition.apiextensions.k8s.io/kubevirts.kubevirt.io created
  26. clusterrole.rbac.authorization.k8s.io/kubevirt.io:operator created
  27. serviceaccount/kubevirt-operator created
  28. clusterrole.rbac.authorization.k8s.io/kubevirt-operator created
  29. clusterrolebinding.rbac.authorization.k8s.io/kubevirt-operator created
  30. deployment.apps/virt-operator created
  31. [root@liabio kubevirt]# kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
  32. kubevirt.kubevirt.io/kubevirt created
  33. [root@liabio kubevirt]# kubectl -n kubevirt wait kv kubevirt --for condition=Available
  34. error: timed out waiting for the condition on kubevirts/kubevirt
  35. [root@liabio kubevirt]#
  36. [root@liabio kubevirt]# kubectl -n kubevirt wait kv kubevirt --for condition=Available
  37. kubevirt.kubevirt.io/kubevirt condition met
  38. [root@liabio kubevirt]# kubectl get cm -n kubevirt
  39. NAME DATA AGE
  40. kubevirt-config 1 77s
  41. kubevirt-install-strategy-ww5wq 1 51s
  42. [root@liabio kubevirt]# kubectl get pod -owide -n kubevirt
  43. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  44. virt-api-f94f8b959-6gcpd 1/1 Running 0 63s 192.168.155.65 liabio <none> <none>
  45. virt-api-f94f8b959-c5hq9 1/1 Running 0 63s 192.168.155.78 liabio <none> <none>
  46. virt-controller-64766f7cbf-dl8tg 1/1 Running 0 41s 192.168.155.80 liabio <none> <none>
  47. virt-controller-64766f7cbf-rbqgv 1/1 Running 0 41s 192.168.155.82 liabio <none> <none>
  48. virt-handler-97d68 1/1 Running 0 41s 192.168.155.83 liabio <none> <none>
  49. virt-operator-754549685-glq58 1/1 Running 0 78s 192.168.155.77 liabio <none> <none>
  50. virt-operator-754549685-krb8l 1/1 Running 0 78s 192.168.155.76 liabio <none> <none>
  51. [root@liabio kubevirt]# ll
  52. -rw-r--r-- 1 root root 875 Sep 18 14:35 fedora-cloud-container-disk-demo-vm.yaml
  53. [root@liabio kubevirt]# kubectl apply -f fedora-cloud-container-disk-demo-vm.yaml
  54. virtualmachineinstance.kubevirt.io/testvmi-nocloud created
  55. [root@liabio kubevirt]#
  56. [root@liabio kubevirt]# kubectl get pod -owide
  57. virt-launcher-testvmi-nocloud-jcxfk 0/2 ContainerCreating 0 31s <none> liabio <none> <none>
  58. [root@liabio kubevirt]# mkdir kubevirt-v0.26.0
  59. [root@liabio kubevirt]# ll
  60. total 593860
  61. -rw-r--r-- 1 root root 875 Sep 18 14:35 fedora-cloud-container-disk-demo-vm.yaml
  62. drwxr-xr-x 2 root root 4096 Sep 22 07:49 kubevirt-v0.26.0
  63. [root@liabio kubevirt]# cd kubevirt-v0.26.0/
  64. [root@liabio kubevirt-v0.26.0]# ll
  65. total 0
  66. [root@liabio kubevirt-v0.26.0]# wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
  67. --2020-09-22 07:49:46-- https://github.com/kubevirt/kubevirt/releases/download/v0.26.0/kubevirt-operator.yaml
  68. Resolving github.com (github.com)... 140.82.113.4
  69. Connecting to github.com (github.com)|140.82.113.4|:443... connected.
  70. HTTP request sent, awaiting response... 302 Found
  71. 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]
  72. --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
  73. Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.89.156
  74. Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.89.156|:443... connected.
  75. HTTP request sent, awaiting response... 200 OK
  76. Length: 10575 (10K) [application/octet-stream]
  77. Saving to: kubevirt-operator.yaml
  78. kubevirt-operator.yaml 100%[===================================================================>] 10.33K --.-KB/s in 0s
  79. 2020-09-22 07:49:48 (132 MB/s) - kubevirt-operator.yaml saved [10575/10575]
  80. [root@liabio kubevirt-v0.26.0]# wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
  81. --2020-09-22 07:49:57-- https://github.com/kubevirt/kubevirt/releases/download/v0.26.0/kubevirt-cr.yaml
  82. Resolving github.com (github.com)... 140.82.113.4
  83. Connecting to github.com (github.com)|140.82.113.4|:443... connected.
  84. HTTP request sent, awaiting response... 302 Found
  85. 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]
  86. --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
  87. Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.28.4
  88. Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.28.4|:443... connected.
  89. HTTP request sent, awaiting response... 200 OK
  90. Length: 139 [application/octet-stream]
  91. Saving to: kubevirt-cr.yaml
  92. kubevirt-cr.yaml 100%[===================================================================>] 139 --.-KB/s in 0s
  93. 2020-09-22 07:49:59 (4.69 MB/s) - kubevirt-cr.yaml saved [139/139]
  94. [root@liabio kubevirt-v0.26.0]# ll
  95. total 16
  96. -rw-r--r-- 1 root root 139 Feb 7 2020 kubevirt-cr.yaml
  97. -rw-r--r-- 1 root root 10575 Feb 7 2020 kubevirt-operator.yaml
  98. [root@liabio kubevirt]# kubectl get pod -owide
  99. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  100. virt-launcher-testvmi-nocloud-jcxfk 2/2 Running 0 3m32s 192.168.155.69 liabio <none> <none>
  101. [root@liabio kubevirt]# kubectl logs -f virt-launcher-testvmi-nocloud-jcxfk compute
  102. {"component":"virt-launcher","level":"info","msg":"Collected all requested hook sidecar sockets","pos":"manager.go:68","timestamp":"2020-09-21T23:49:38.229909Z"}
  103. {"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"}
  104. {"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"}
  105. {"component":"virt-launcher","level":"info","msg":"Connecting to libvirt daemon: qemu:///system","pos":"libvirt.go:355","timestamp":"2020-09-21T23:49:38.237415Z"}
  106. {"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"}
  107. {"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"}
  108. {"component":"virt-launcher","level":"info","msg":"hostname: testvmi-nocloud","subcomponent":"libvirt","thread":"39","timestamp":"2020-09-21T23:49:38.286000Z"}
  109. {"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"}
  110. {"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"}
  111. {"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"}
  112. {"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"}
  113. {"component":"virt-launcher","level":"info","msg":"Connected to libvirt daemon","pos":"libvirt.go:371","timestamp":"2020-09-21T23:49:38.740524Z"}
  114. {"component":"virt-launcher","level":"info","msg":"Registered libvirt event notify callback","pos":"client.go:294","timestamp":"2020-09-21T23:49:38.897166Z"}
  115. {"component":"virt-launcher","level":"info","msg":"Marked as ready","pos":"virt-launcher.go:73","timestamp":"2020-09-21T23:49:38.897611Z"}
  116. {"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"}
  117. {"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"}
  118. {"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"}
  119. {"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"}
  120. {"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"}
  121. {"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"}
  122. {"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"}
  123. {"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"}
  124. {"component":"virt-launcher","level":"info","msg":"Starting SingleClientDHCPServer","pos":"dhcp.go:64","timestamp":"2020-09-21T23:49:44.085226Z"}
  125. {"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"}
  126. {"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"}
  127. {"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"}
  128. {"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"}
  129. {"component":"virt-launcher","level":"info","msg":"DomainLifecycle event 0 with reason 0 received","pos":"client.go:259","timestamp":"2020-09-21T23:49:44.160250Z"}
  130. {"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"}
  131. {"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"}
  132. {"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Paused(3):StartingUp(11)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.226818Z"}
  133. {"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"}
  134. {"component":"virt-launcher","level":"info","msg":"Monitoring loop: rate 1s start timeout 5m0s","pos":"monitor.go:237","timestamp":"2020-09-21T23:49:44.235160Z"}
  135. {"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"}
  136. {"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Paused(3):StartingUp(11)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.481544Z"}
  137. {"component":"virt-launcher","level":"info","msg":"DomainLifecycle event 4 with reason 0 received","pos":"client.go:259","timestamp":"2020-09-21T23:49:44.670951Z"}
  138. {"component":"virt-launcher","level":"info","msg":"DomainLifecycle event 2 with reason 0 received","pos":"client.go:259","timestamp":"2020-09-21T23:49:44.672248Z"}
  139. {"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"}
  140. {"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"}
  141. {"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Running(1):Unknown(1)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.677291Z"}
  142. {"component":"virt-launcher","level":"info","msg":"kubevirt domain status: Running(1):Unknown(1)","pos":"client.go:180","timestamp":"2020-09-21T23:49:44.684449Z"}
  143. {"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"}
  144. {"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"}
  145. {"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"}
  146. {"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"}
  147. {"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"}
  148. {"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"}
  149. {"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"}
  150. [root@liabio kubevirt]#
  151. [root@liabio kubevirt]#
  152. [root@liabio kubevirt]#
  153. [root@liabio kubevirt]# kubectl get pod -owide
  154. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  155. miniprog-56d87d84cf-4p7xl 1/1 Running 0 50d 192.168.155.87 liabio <none> <none>
  156. mysql-79bd6fcfd-chxr4 1/1 Running 1 50d 192.168.155.88 liabio <none> <none>
  157. redis-0 1/1 Running 0 50d 192.168.155.89 liabio <none> <none>
  158. solo-9bf6f7764-knb4r 1/1 Running 0 50d 10.0.9.52 liabio <none> <none>
  159. virt-launcher-testvmi-nocloud-jcxfk 2/2 Running 0 6m32s 192.168.155.69 liabio <none> <none>
  160. [root@liabio kubevirt]#
  161. [root@liabio kubevirt]# kubectl get pod -owide
  162. ^C
  163. [root@liabio kubevirt]# kubectl get pod -owide -n kubevirt

参考

官方部署文档