export VERSION=$(curl -s https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)
echo $VERSION
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.phase}"
kubectl wait kubevirt.kubevirt.io/kubevirt -n kubevirt \
--for=jsonpath='{.status.phase}=Deployed' --timeout=120s
kubectl get all -n kubevirt
VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
echo ${ARCH}
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
chmod +x virtctl
sudo install virtctl /usr/local/bin
# or
kubectl krew install virt
bat vm.yaml
kubectl apply -f vm.yaml
kubectl get vms
kubectl get vms -o yaml testvm
virtctl start testvm
# or
kubectl virt start testvm
# or
kubectl patch virtualmachine testvm --type merge -p \
'{"spec":{"running":true}}'
Tip
VirtualMachine defines the desired state of a VM, while VirtualMachineInstance represents the actual running instance of the VM within Kubernetes.
kubectl get vmis
kubectl get vmis -o yaml testvm
virtctl console testvm
kubectl virt stop testvm
kubectl delete vm testvm
kubectl create secret generic my-pub-key --from-file=key1=${HOME}/.ssh/id_rsa.pub
bat ssh-vm.yaml
kubectl create -f ssh-vm.yaml
kubectl get vm,vmi,pod
kubectl virt ssh fedora@testvm --local-ssh=true
# run this on the VM
curl -k https://kubernetes:443
# run this in the k8s cluster
kubectl create -f nginx.yaml
# run this on the VM
curl http://nginx-service