Version 1.12. This version is no longer supported. For information about how to upgrade to version 1.13, seeUpgrading Anthos on bare metalin the 1.13 documentation. For more information about supported and unsupported versions, see theVersion historypage in the latest documentation.
This quickstart shows you how to use VM Runtime on Google Distributed Cloud to create a
virtual machine (VM) on Google Distributed Cloud. VM Runtime on Google Distributed Cloud usesKubeVirtto orchestrate VMs on clusters, and lets you work with your VM-based apps and
workloads in a uniform development environment.
Before you begin
To complete this quickstart, you need access to Google Distributed Cloud version
1.12 (anthosBareMetalVersion: 1.12) or higher cluster. You can use any
cluster type capable of running workloads. If needed,try Google Distributed Cloud on Compute Engineor see thecluster creation overview.
Enable VM Runtime on Google Distributed Cloud
VM Runtime on Google Distributed Cloud is automatically installed in Google Distributed Cloud
version 1.10 or higher, but is disabled by default. Before you can run VM
resources in your Google Distributed Cloud, you must enable the
VM Runtime on Google Distributed Cloud.
bmctl
Google Distributed Cloud version 1.11 or higher can use thebmctlcommand-line tool:
To enable the runtime, use thebmctltool:
bmctlenablevmruntime--kubeconfigKUBECONFIG_PATH
Provide the path to the kubeconfig file for your cluster.
Google Distributed Cloud generates the kubeconfig file on the admin
workstation when you create a cluster. By default, the path isbmctl-workspace/CLUSTER_NAME/CLUSTER_NAME-kubeconfig.
If VM Runtime on Google Distributed Cloud is already enabled, the command returns an
error.
Custom resource
Google Distributed Cloud version 1.10 or higher can use a custom resource definition
to enable VM Runtime on Google Distributed Cloud. This custom resource is installed by
default.
Edit theVMRuntimecustom resource:
kubectleditvmruntime
Setenabled:truein the spec:
apiVersion:vm.cluster.gke.io/v1kind:VMRuntimemetadata:name:vmruntimespec:enabled:true# useEmulation defaults to "false" if not set.useEmulation:true# vmImageFormat defaults to "qcow2" if not set.vmImageFormat:qcow2
In the precedingspecsection, the following values can be set:
enabled: set to true to enable VM Runtime on Google Distributed Cloud
useEmulation: If your node doesn't support hardware virtualization, or
you aren't sure, set the value to true. If available, hardware
virtualization provides better performance than software emulation. TheuseEmulationfield defaults tofalse, if it isn't specified.
vmImageFormat: Supports two disk image format values:rawandqcow2. If you don't setvmImageFormat, the
VM Runtime on Google Distributed Cloud uses therawdisk image format to create
VMs. Therawformat may provide improved performance overqcow2, a
copy on write format, but may use more disk. For more information about
the image formats for your VM, seeDisk image file formatsin the QEMU documentation.
Save the custom resource in your editor.
Verify that theVMRuntimecustom resource is enabled:
kubectldescribevmruntimevmruntime
The details of theVMRuntimecustom resource include aStatussection.
VM Runtime on Google Distributed Cloud is enabled and working whenVMRuntime.Status.Readyshows astrue.
The credentials let you authenticate and download thevirtctlclient tool,
then install to/usr/bin/kubectl-virton your local machine.
Verify that thevirtctlplugin is installed:
kubectlpluginlist
Ifkubectl-virtis listed in the response, the plugin is successfully
installed.
Ifkubectl-virtis not listed, check theinstall-virtctl.logfile as noted
in the output of the previousbmctl installcommand, such asbmctl-workspace/log/install-virtctl-[date]/install-virtctl.log.
Create a VM
In this quickstart, you create a VM that uses a public VM image and default
credentials.
Create a VM in your cluster. Thevirtctlplugin is used with thekubectlcommand:
This command creates anUbuntu 20.04VM and defaults of2CPU,4Gimemory, and a20Giboot disk inReadWriteOncemode using thelocal-sharedstorage class. Replace the following values:
VM_NAME: name for your VM. VM names
must contain only lowercase alphanumeric characters or '-', start and end
with an alphanumeric character, and contain at most 63 characters. For
more information, seeRFC 1123 Label Namesin the Kubernetes documentation.
USERNAME: user name for the account to create on the
VM.
PASSWORD: password for the user account.
If you receive an error about CLI parameters, verify that your cluster is at
version1.11.1or higher and that you have the latest version of thevirtctlclient tool. For more information about CLI errors, consult the
console log. For username and password rules, see the documentation for the
guest operating system (OS). If something isn't working as expected, check forVM Runtime on Google Distributed Cloud known issues.
It can take a few minutes to create the VM. Check the status of the VM with
thekubectlcommand:
kubectlgetgvm
The following example output shows the VM in aRunningstate:
NAME STATUS AGE IP
vm-sample1 Running 64s 192.168.2.124
Connect to your VM
When your VM is running, connect to the console of the VM.
To access a VM from the console, usekubectl:
kubectlvirtconsoleVM_NAME
When prompted, enter the user credentials you specified to create the VM.
After you have successfully connected to the console of the VM, exit the VM
session and console:
Ctrl+]
Clean up
To clean up the resources created in this quickstart, follow these steps.
To delete the VM and associated DataVolume, usekubectl:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eVM Runtime on Google Distributed Cloud allows you to create and manage virtual machines (VMs) using KubeVirt, providing a unified environment for VM-based workloads.\u003c/p\u003e\n"],["\u003cp\u003eTo begin, you need a Google Distributed Cloud cluster version 1.12 or higher, and you must enable the VM Runtime feature, which can be done via the \u003ccode\u003ebmctl\u003c/code\u003e tool or by editing the \u003ccode\u003eVMRuntime\u003c/code\u003e custom resource.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003evirtctl\u003c/code\u003e client tool is required to create and manage VMs, and it can be installed as a \u003ccode\u003ekubectl\u003c/code\u003e plugin.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a VM by using the \u003ccode\u003ekubectl virt create vm\u003c/code\u003e command, specifying parameters like the VM name, image, username, and password, which will set up a VM with default specifications.\u003c/p\u003e\n"],["\u003cp\u003eOnce the VM is running you can connect to it using the \u003ccode\u003ekubectl virt console\u003c/code\u003e command and logging in with the credentials you provided.\u003c/p\u003e\n"]]],[],null,["# Quickstart: Create a VM in Google Distributed Cloud\n\n\u003cbr /\u003e\n\nThis quickstart shows you how to use VM Runtime on Google Distributed Cloud to create a\nvirtual machine (VM) on Google Distributed Cloud. VM Runtime on Google Distributed Cloud uses\n[KubeVirt](https://kubevirt.io/)\nto orchestrate VMs on clusters, and lets you work with your VM-based apps and\nworkloads in a uniform development environment.\n\nBefore you begin\n----------------\n\nTo complete this quickstart, you need access to Google Distributed Cloud version\n1.12 (`anthosBareMetalVersion: 1.12`) or higher cluster. You can use any\ncluster type capable of running workloads. If needed,\n[try Google Distributed Cloud on Compute Engine](/anthos/clusters/docs/bare-metal/1.12/try/gce-vms)\nor see the\n[cluster creation overview](/anthos/clusters/docs/bare-metal/1.12/installing/creating-clusters/create-clusters-overview).\n\nEnable VM Runtime on Google Distributed Cloud\n---------------------------------------------\n\nVM Runtime on Google Distributed Cloud is automatically installed in Google Distributed Cloud\nversion 1.10 or higher, but is disabled by default. Before you can run VM\nresources in your Google Distributed Cloud, you must enable the\nVM Runtime on Google Distributed Cloud. \n\n### bmctl\n\nGoogle Distributed Cloud version 1.11 or higher can use the `bmctl` command-line tool:\n\n- To enable the runtime, use the `bmctl` tool:\n\n bmctl enable vmruntime --kubeconfig \u003cvar label=\"Kubeconfig path\" translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e\n\n Provide the path to the kubeconfig file for your cluster.\n Google Distributed Cloud generates the kubeconfig file on the admin\n workstation when you create a cluster. By default, the path is\n `bmctl-workspace/`\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e`/`\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e`-kubeconfig`.\n\n If VM Runtime on Google Distributed Cloud is already enabled, the command returns an\n error.\n\n### Custom resource\n\nGoogle Distributed Cloud version 1.10 or higher can use a custom resource definition\nto enable VM Runtime on Google Distributed Cloud. This custom resource is installed by\ndefault.\n\n1. Edit the `VMRuntime` custom resource:\n\n kubectl edit vmruntime\n\n2. Set `enabled:true` in the spec:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VMRuntime\n metadata:\n name: vmruntime\n spec:\n enabled: true\n # useEmulation defaults to \"false\" if not set.\n useEmulation: true\n # vmImageFormat defaults to \"qcow2\" if not set.\n vmImageFormat: qcow2\n\n In the preceding `spec` section, the following values can be set:\n - `enabled`: set to true to enable VM Runtime on Google Distributed Cloud\n - `useEmulation`: If your node doesn't support hardware virtualization, or you aren't sure, set the value to true. If available, hardware virtualization provides better performance than software emulation. The `useEmulation` field defaults to `false`, if it isn't specified.\n - `vmImageFormat`: Supports two disk image format values: `raw` and `qcow2`. If you don't set `vmImageFormat`, the VM Runtime on Google Distributed Cloud uses the `raw` disk image format to create VMs. The `raw` format may provide improved performance over `qcow2`, a copy on write format, but may use more disk. For more information about the image formats for your VM, see [Disk image file formats](https://www.qemu.org/docs/master/system/images.html#disk-image-file-formats) in the QEMU documentation.\n3. Save the custom resource in your editor.\n\n4. Verify that the `VMRuntime` custom resource is enabled:\n\n kubectl describe vmruntime vmruntime\n\n The details of the `VMRuntime` custom resource include a `Status` section.\n VM Runtime on Google Distributed Cloud is enabled and working when\n `VMRuntime.Status.Ready` shows as `true`.\n\nInstall the `virtctl` client tool\n---------------------------------\n\nTo create and manage VMs, install the\n[virtctl client tool](https://kubevirt.io/user-guide/operations/virtctl_client_tool/).\n\n1. Install the `virtctl` client tool as a `kubectl` plugin:\n\n export GOOGLE_APPLICATION_CREDENTIALS=\"\u003cvar label=\"name\" translate=\"no\"\u003ePATH_TO_SERVICE_ACCOUNT_KEY\u003c/var\u003e/bm-gcr.json\"\n sudo -E bmctl install virtctl\n\n The credentials let you authenticate and download the `virtctl` client tool,\n then install to `/usr/bin/kubectl-virt` on your local machine.\n2. Verify that the `virtctl` plugin is installed:\n\n kubectl plugin list\n\n If `kubectl-virt` is listed in the response, the plugin is successfully\n installed.\n\n If `kubectl-virt` is not listed, check the `install-virtctl.log` file as noted\n in the output of the previous `bmctl install` command, such as\n `bmctl-workspace/log/install-virtctl-[date]/install-virtctl.log`.\n\nCreate a VM\n-----------\n\nIn this quickstart, you create a VM that uses a public VM image and default\ncredentials.\n\n1. Create a VM in your cluster. The `virtctl` plugin is used with the\n `kubectl` command:\n\n kubectl virt create vm \u003cvar label=\"name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n --image ubuntu20.04 \\\n --configure-initial-password \u003cvar label=\"username\" translate=\"no\"\u003eUSERNAME\u003c/var\u003e:\u003cvar label=\"name\" translate=\"no\"\u003ePASSWORD\u003c/var\u003e\n\n This command creates an *Ubuntu 20.04* VM and defaults of *2* CPU, *4Gi*\n memory, and a *20Gi* boot disk in *ReadWriteOnce* mode using the\n *local-shared* storage class. Replace the following values:\n - \u003cvar scope=\"VM_NAME\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e: name for your VM. VM names must contain only lowercase alphanumeric characters or '-', start and end with an alphanumeric character, and contain at most 63 characters. For more information, see [RFC 1123 Label Names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names) in the Kubernetes documentation.\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: user name for the account to create on the VM.\n - \u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e: password for the user account.\n\n If you receive an error about CLI parameters, verify that your cluster is at\n version `1.11.1` or higher and that you have the latest version of the\n `virtctl` client tool. For more information about CLI errors, consult the\n console log. For username and password rules, see the documentation for the\n guest operating system (OS). If something isn't working as expected, check for\n [VM Runtime on Google Distributed Cloud known issues](/anthos/clusters/docs/bare-metal/1.12/troubleshooting/known-issues#anthos_vm_runtime).\n | **Note:** The preceding command creates a YAML file, such as `vm-sample1.yaml`, in the `~/google-virtctl` directory. You can view the content of this file to see the definition of the Kubernetes resources that were created by VM Runtime on Google Distributed Cloud.\n2. It can take a few minutes to create the VM. Check the status of the VM with\n the `kubectl` command:\n\n kubectl get gvm\n\n The following example output shows the VM in a `Running` state: \n\n NAME STATUS AGE IP\n vm-sample1 Running 64s 192.168.2.124\n\nConnect to your VM\n------------------\n\nWhen your VM is running, connect to the console of the VM.\n\n1. To access a VM from the console, use `kubectl`:\n\n kubectl virt console \u003cvar scope=\"VM_NAME\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n2. When prompted, enter the user credentials you specified to create the VM.\n\n3. After you have successfully connected to the console of the VM, exit the VM\n session and console:\n\n Ctrl + ]\n\nClean up\n--------\n\nTo clean up the resources created in this quickstart, follow these steps.\n\n1. To delete the VM and associated DataVolume, use `kubectl`:\n\n kubectl virt delete vm \u003cvar scope=\"VM_NAME\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e --all\n\nWhat's next\n-----------\n\n- [Manage the power state of a VM in Google Distributed Cloud](/anthos/clusters/docs/bare-metal/1.12/vm-runtime/manage-power-state).\n- [Edit a VM in Google Distributed Cloud](/anthos/clusters/docs/bare-metal/1.12/vm-runtime/edit-vm).\n- [View VM console logs in Google Distributed Cloud](/anthos/clusters/docs/bare-metal/1.12/vm-runtime/view-console-logs)."]]