kubevirt 用法
Install tools
install kubevirt: https://kubebyexample.com/learning-paths/kubevirt-fundamentals/guided-exercise-installing-kubevirt (Tiber install, no need import)
install krew ref https://krew.sigs.k8s.io/docs/user-guide/setup/install/ (manually installation)
Install virtctl: https://kubevirt.io/user-guide/user_workloads/virtctl_client_tool/ (manually installation)
kubectl api-resources | grep kubevirt |
Hello World VM ref: https://docs.starlingx.io/kube-virt/hello-world-kubevirt-vm-05503659173c.html
VM yaml
apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: testvm spec: running: false template: metadata: labels: kubevirt.io/size : small kubevirt.io/domain : testvm spec: domain: devices: disks: - name : containerdisk disk: bus: virtio - name : cloudinitdisk disk: bus: virtio interfaces: - name : default masquerade: { } resources: requests: memory: 64M networks: - name : default pod: { } volumes: - name : containerdisk containerDisk: image: quay.io/kubevirt/cirros-container-disk-demo - name : cloudinitdisk cloudInitNoCloud: userDataBase64: SGkuXG4= |
There is an example on github: intel-iot-devkit/sample-helm-charts: This repository contains sample helm charts for container and vm-based workload deployments. (github.com)
kubectl virt create vm --help
kubectl virt create vm --name my-vm --memory 256Mi | kubectl create -f -
kubectl virt create vm --name my-vm --memory=1Gi --volume-containerdisk=src:my.registry/my-image:my-tag
kubectl virt create instancetype --cpu 2 --memory 256Mi
Create VM by webUI
REF:
kubevirt-manager.io: get started, github:kubevirt-manager/kubevirt-manager: Kubevirt Web UI / Web Interface Manager (github.com)
KubeVirt Web User Interface github: https://github.com/kubevirt/web-ui
Kubernetes Management Platform | Portainer 是不是也支持,需要调查一下。
kubectl apply -f https://raw.githubusercontent.com/kubevirt-manager/kubevirt-manager/main/kubernetes/bundled.yaml # 使用端口转发来访问集群中的应用 | Kubernetes kubectl get node -o wide kubectl port-forward -n kubevirt-manager service/kubevirt-manager 28080:8080 clusterip=$(kubectl -n kubevirt-manager get svc -l app=kubevirt-manager -o jsonpath='{.items[0].spec.clusterIP}') echo "copy the var to edge node: clusterip=$clusterip" sudo apt install socat -y IPADDR=$(ip route get 1 | head -n 1 | grep -o 'src\s[.0-9a-z]\+' | awk '{print $2}') echo "login windows and open a browser with http://$IPADDR:8080" clusterip=$clusterip sudo ufw allow 8080/tcp socat TCP-LISTEN:8080,fork TCP:${clusterip}:8080
Get the VM configure
kubectl get vm -o yaml
kubectl get vmi -o yaml
clusterip