Getting Started with VM Runtime
In this part, you will know how to use kubectl to create a VM using a public image and default credentials. You will also know how to connect to the VM after it is created and delete it when you no longer need it.
- Create a VM.
Create a VM in the cluster. The virtctl add-on is used together with the kubectl command. Run the following command to create a VM that uses the CirrOS image. By default, the VM uses the default storage class and has two vCPUs, 4-GiB memory, and a 20-GiB boot disk in ReadWriteOnce mode.
virtctl create vm --name VM_NAME --volume-containerdisk src:quay.io/kubevirt/cirros-container-disk-demo:latest --memory "4Gi" | kubectl create -f -
Configure VM_NAME as follows:
- VM_NAME: Enter up to 63 characters. Start and end with a lowercase letter or digit. Only lowercase letters, digits, and hyphens (-) are allowed.
The following is an example:
- Create a VM named testvm.
virtctl create vm --name testvm --volume-containerdisk src:quay.io/kubevirt/cirros-container-disk-demo:latest --memory "4Gi" | kubectl create -f –
- Wait for a while and run the following command to check the VM status:
kubectl get vm
The following example output shows that the VM is in the Running state:NAME AGE STATUS READY testvm 54s Running True
- Create a VM named testvm.
- VM_NAME: Enter up to 63 characters. Start and end with a lowercase letter or digit. Only lowercase letters, digits, and hyphens (-) are allowed.
- Connect to the VM.
Access the VM console when the VM is running.
- To access a VM through the console, run the following virtctl command:
virtctl console testvm
You will see the following information:Successfully connected to testvm console. The escape sequence is ^]
- Press Enter. The following information is displayed:
login as 'cirros' user. default password: 'gocubsgo'. use 'sudo' for root. login:
- Enter the username and password, for example, cirros and gocubsgo.
After the VM console is successfully connected, exit the VM session and console.
Ctrl + ]
- To access a VM through the console, run the following virtctl command:
- Delete the VM and its associated DataVolume.
kubectl delete vm testvm
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot