Create a VM with specific CPU and memory resources using VM Runtime on GDC
Stay organized with collections
Save and categorize content based on your preferences.
This document is intended for application owners and platform administrators
that run Google Distributed Cloud. This document shows you how to create and use VM
types or manually specify CPU and memory resources when you create VMs that use
VM Runtime on GDC.
Before you begin
To complete this document, you need access to the following resources:
When you create a VM, you can manually specify the CPU and memory requirements.
This ability lets you create VMs with the appropriate compute resources to match
your application needs.
To create a VM and manually specify the CPU and memory requirements, use the
following steps.
When you enable VM Runtime on GDC, a new VirtualMachineType custom
resource definition is available. This definition is used to specify CPU and
memory resources of a VM. You can create VM types for the different workloads
you need, and apply a consistent set of compute resources to VMs based on these
types.
If VM Runtime on GDC is enabled in Google Distributed Cloud, the
vm-controller-manager installs a predefined VM type. The following definition
shows the default example-machinetype VM type:
You can't update this predefined VM type. This predefined VM type is
re-installed if it doesn't exist in the cluster every time the
vm-controller-manager is started or restarted, such as if you deleted the VM
type.
Create a VM type
You can create your own VM types to fit the compute needs of your workloads.
Create a VirtualMachineType manifest such as my-vm-type.yaml, in the
editor of your choice:
In this YAML file, specify the name of your custom VM type that you created in
the previous section, such as my-vm-type, as the value for
the virtualMachineTypeName.
The VM connects eth0 to the default pod-network network.
[[["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-08-29 UTC."],[],[],null,["# Create a VM with specific CPU and memory resources using VM Runtime on GDC\n\nThis document is intended for application owners and platform administrators\nthat run Google Distributed Cloud. This document shows you how to create and use VM\ntypes or manually specify CPU and memory resources when you create VMs that use\nVM Runtime on GDC.\n\nBefore you begin\n----------------\n\nTo complete this document, you need access to the following resources:\n\n- Access to Google Distributed Cloud version 1.12.0 (`anthosBareMetalVersion: 1.12.0`) or higher cluster. You can use any cluster type capable of running workloads. If needed, [try Google Distributed Cloud on Compute Engine](/kubernetes-engine/distributed-cloud/bare-metal/docs/try/gce-vms) or see the [cluster creation overview](/kubernetes-engine/distributed-cloud/bare-metal/docs/installing/creating-clusters/create-clusters-overview).\n- The `virtctl` client tool installed as a plugin for `kubectl`. If needed, [install the virtctl client tool](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/quickstart#install_the_virtctl_client_tool).\n\nCreate a VM\n-----------\n\nWhen you create a VM, you can manually specify the CPU and memory requirements.\nThis ability lets you create VMs with the appropriate compute resources to match\nyour application needs.\n\nTo create a VM and manually specify the CPU and memory requirements, use the\nfollowing steps. \n\n### CLI\n\n- Use `kubectl` to create a VM:\n\n kubectl virt create vm \u003cvar label=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n --image ubuntu20.04 \\\n --cpu \u003cvar label=\"vcpu_number\" translate=\"no\"\u003eCPU_NUMBER\u003c/var\u003e \\\n --memory \u003cvar label=\"memory_size\" translate=\"no\"\u003eMEMORY_SIZE\u003c/var\u003e\n\n Replace the following values:\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name for your VM. For more information on name constraints, see [Object names and IDs](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/).\n - \u003cvar translate=\"no\"\u003eCPU_NUMBER\u003c/var\u003e: The number of virtual CPUs (vCPUs)to assign to the VM.\n - You can assign between 1 and 96 vCPUs to a VM.\n - \u003cvar translate=\"no\"\u003eMEMORY_SIZE\u003c/var\u003e: The amount of memory to assign to the VM.\n - You can assign between 1M and 1T of memory to a VM. For more information, see [Memory resource units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).\n\n | **Note:** In the `~/google-virtctl` directory, a \u003cvar scope=\"VM_NAME\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e`.yaml` file is created. You can view the content of this file to see the definition of the Kubernetes resources that were created by the VM Runtime on GDC.\n\n### Manifest\n\n1. Create a `VirtualMachine` manifest, such as *my-custom-vm.yaml*, in the\n editor of your choice:\n\n nano my-custom-vm.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachine\n metadata:\n name: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n compute:\n cpu:\n vcpus: \u003cvar label=\"vcpu_number\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVCPU_NUMBER\u003c/span\u003e\u003c/var\u003e\n memory:\n capacity: \u003cvar label=\"memory_size\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eMEMORY_SIZE\u003c/span\u003e\u003c/var\u003e\n interfaces:\n - name: eth0\n networkName: pod-network\n default: true\n disks:\n - virtualMachineDiskName: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e-boot-dv\n boot: true\n\n In this YAML file, define the following settings:\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name for your VM. For more information on name constraints, see [Object names and IDs](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/).\n - \u003cvar translate=\"no\"\u003eVCPU_NUMBER\u003c/var\u003e: The number of vCPUs to assign to the VM.\n - You can assign between 1 and 96 vCPUs to a VM.\n - \u003cvar translate=\"no\"\u003eMEMORY_SIZE\u003c/var\u003e: The amount of memory to assign to the VM.\n - You can assign between 1M and 1T of memory to a VM. For more information, see [Memory resource units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).\n\n The VM connects `eth0` to the default `pod-network` network.\n\n The boot disk named \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e`-boot-dv` must already\n exist. For more information, see\n [Create and manage virtual disks](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-manage-disks).\n3. Save and close the VM manifest in your editor.\n\n4. Create the VM using `kubectl`:\n\n kubectl apply -f my-custom-vm.yaml\n\nCreate and use VM types\n-----------------------\n\nWhen you enable VM Runtime on GDC, a new *VirtualMachineType* custom\nresource definition is available. This definition is used to specify CPU and\nmemory resources of a VM. You can create VM types for the different workloads\nyou need, and apply a consistent set of compute resources to VMs based on these\ntypes.\n\nIf VM Runtime on GDC is enabled in Google Distributed Cloud, the\n`vm-controller-manager` installs a predefined VM type. The following definition\nshows the default `example-machinetype` VM type: \n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachineType\n metadata:\n name: \"example-machinetype\"\n labels:\n vm.cluster.gke.io/predefined-machinetype: \"true\"\n spec:\n cpu:\n vcpus: 2\n memory:\n capacity: 4G\n\nYou can't update this predefined VM type. This predefined VM type is\nre-installed if it doesn't exist in the cluster every time the\n`vm-controller-manager` is started or restarted, such as if you deleted the VM\ntype.\n\n### Create a VM type\n\nYou can create your own VM types to fit the compute needs of your workloads.\n\n1. Create a `VirtualMachineType` manifest such as *my-vm-type.yaml*, in the\n editor of your choice:\n\n nano my-vm-type.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachineType\n metadata:\n name: \u003cvar label=\"VM type name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003emy-vm-type\u003c/span\u003e\u003c/var\u003e\n spec:\n cpu:\n vcpus: \u003cvar label=\"vcpu_number\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVCPU_NUMBER\u003c/span\u003e\u003c/var\u003e\n memory:\n capacity: \u003cvar label=\"memory_size\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eMEMORY_SIZE\u003c/span\u003e\u003c/var\u003e\n\n In this VM type, you define the following settings:\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name for your VM. For more information on name constraints, see [Object names and IDs](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/).\n - \u003cvar translate=\"no\"\u003eVCPU_NUMBER\u003c/var\u003e: The number of vCPUs to assign to the VM.\n - You can assign between 1 and 96 vCPUs to a VM.\n - \u003cvar translate=\"no\"\u003eMEMORY_SIZE\u003c/var\u003e: The amount of memory to assign to the VM.\n - You can assign between 1M and 1T of memory to a VM. For more information, see [Memory resource units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).\n3. Save and close the VM type manifest in your editor.\n\n4. Create the VM type using `kubectl`:\n\n kubectl apply -f my-vm-type.yaml\n\n### Create a VM using a VM type\n\nSpecify a VM type in your `VirtualMachine` manifest to apply predefined\n`compute` settings to your VM.\n\n1. Create a `VirtualMachine` manifest, such as *my-custom-vm.yaml*, in the\n editor of your choice.\n\n nano my-custom-vm.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachine\n metadata:\n name: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n compute:\n virtualMachineTypeName: \u003cvar label=\"vm_type_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003emy-vm-type\u003c/span\u003e\u003c/var\u003e\n interfaces:\n - name: eth0\n networkName: pod-network\n default: true\n disks:\n - virtualMachineDiskName: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e-boot-dv\n boot: true\n\n In this YAML file, specify the name of your custom VM type that you created in\n the previous section, such as \u003cvar translate=\"no\"\u003emy-vm-type\u003c/var\u003e, as the value for\n the `virtualMachineTypeName`.\n\n The VM connects `eth0` to the default `pod-network` network.\n\n The boot disk named \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e`-boot-dv` must already\n exist. For more information, see\n [Create and manage virtual disks](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-manage-disks).\n3. Save and close the VM manifest in your editor.\n\n4. Create the VM using `kubectl`:\n\n kubectl apply -f my-custom-vm.yaml\n\nWhat's next\n-----------\n\n- [Edit a VM in Google Distributed Cloud](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/edit-vm).\n- When you no longer need VMs, [Delete a VM in Google Distributed Cloud](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/delete)."]]