minikube addons enable kubevirt
export VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- '-rc' | sort -r | head -1 | awk -F': ' '{print $2}' | sed 's/,//' | xargs)
echo $VERSION
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
-
Make sure git is installed.
-
Download krew.exe from the Releases page to a directory.
-
Launch a command prompt with administrator privileges and navigate to that directory.
-
Run the following command to install krew
.\krew install krew
-
Add the %USERPROFILE%.krew\bin directory to your PATH environment variable
-
Launch a new command-line window.
-
Run
kubectl krew
to check the installation. -
Run
kubectl krew install virt
to install virtctl( to be used as kubectl virt )
-
Use any of the manifest file of linux, in this case, we are using cirros.yaml
-
Run
kubectl create -f cirros.yaml
to create vm -
Run
kubectl get vms
to check status of vm -
Start the vm by running the command
kubectl virt start cirros
-
Run
kubectl get vmi
to check status of vm instance -
Once the phase status in above command changes to Running, run the following command to access vm
kubectl virt console cirros
-
Disconnect from vm console by typing ctrl+]
-
To shut down vm instance, run
kubectl virt stop cirros
- To delete vm, run
kubectl delete vm cirros
-
Download windows iso file
-
Install CDI by running the following commands
export VERSION=$(curl -s https://api.github.com/repos/kubevirt/containerized-data-importer/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-operator.yaml
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-cr.yaml
- Upload the folder of the windows iso file using docker (Change the FILE_PATH)
docker run -it -d -p 8080:80 --name web -v {FILE_PATH}:/usr/local/apache2/htdocs/ httpd:2.4
-
localhost:8080 has the uploaded folder, copy the path of iso file to used in step 7
-
Run
kubectl create -f window-pvc.yaml
to create PVC -
Make these necessary changes to windows.yaml
- Change the URL to the path of iso file
- Change localhost to host.minikube.internal
- Run
kubectl create -f window.yaml
to create VM
- It will take some time for the windows file to be uploaded
-
Run
kubectl get vms
to check status of vm -
Start the vm by running the command
kubectl virt start vm-windows-datavolume
-
Run
kubectl get vmi
to check status of vm instance -
Once the phase status in above command changes to Running, run the following command to access vm
kubectl virt vnc vm-windows-datavolume -proxy-only
-
Above command will show the PORT_NUMBER where we can access windows
-
In any vnc viewer, enter url- 127.0.0.1::{PORT_NUMBER} to access windows.