Membuat VM dengan resource CPU dan memori tertentu menggunakan Runtime VM di GDC
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini ditujukan untuk pemilik aplikasi dan administrator platform
yang menjalankan Google Distributed Cloud. Dokumen ini menunjukkan cara membuat dan menggunakan jenis VM atau menentukan resource CPU dan memori secara manual saat Anda membuat VM yang menggunakan Runtime VM di GDC.
Sebelum memulai
Untuk menyelesaikan dokumen ini, Anda memerlukan akses ke resource berikut:
Akses ke cluster Google Distributed Cloud versi 1.12.0 (anthosBareMetalVersion: 1.12.0)
atau yang lebih tinggi. Anda dapat menggunakan jenis cluster apa pun yang dapat menjalankan beban kerja.
Jika diperlukan,
coba Google Distributed Cloud di Compute Engine
atau lihat
ringkasan pembuatan cluster.
Alat klien virtctl yang diinstal sebagai plugin untuk kubectl. Jika diperlukan,
instal alat klien virtctl.
Membuat VM
Saat membuat VM, Anda dapat menentukan persyaratan CPU dan memori secara manual.
Kemampuan ini memungkinkan Anda membuat VM dengan resource komputasi yang sesuai untuk menyesuaikan
kebutuhan aplikasi Anda.
Untuk membuat VM dan menentukan persyaratan CPU dan memori secara manual, gunakan
langkah-langkah berikut.
VM_NAME: nama untuk VM Anda. Untuk informasi selengkapnya tentang batasan nama, lihat Nama dan ID objek.
VCPU_NUMBER: Jumlah vCPU yang akan ditetapkan ke VM.
Anda dapat menetapkan antara 1 hingga 96 vCPU ke VM.
MEMORY_SIZE: Jumlah memori yang akan ditetapkan ke VM.
Anda dapat menetapkan memori antara 1 M dan 1 T ke VM. Untuk mengetahui informasi
selengkapnya, lihat
Unit resource memori.
VM menghubungkan eth0 ke jaringan pod-network default.
Disk booting bernama VM_NAME-boot-dv harus sudah
ada. Untuk mengetahui informasi selengkapnya, lihat
Membuat dan mengelola disk virtual.
Simpan dan tutup manifes VM di editor Anda.
Buat VM menggunakan kubectl:
kubectlapply-fmy-custom-vm.yaml
Membuat dan menggunakan jenis VM
Saat Anda mengaktifkan Runtime VM di GDC, definisi resource kustom VirtualMachineType baru akan tersedia. Definisi ini digunakan untuk menentukan resource CPU dan
memori VM. Anda dapat membuat jenis VM untuk berbagai workload
yang diperlukan, dan menerapkan kumpulan resource komputasi yang konsisten ke VM berdasarkan jenis VM ini.
Jika Runtime VM di GDC diaktifkan di Google Distributed Cloud, vm-controller-manager akan menginstal jenis VM yang telah ditentukan. Definisi berikut
menunjukkan jenis VM example-machinetype default:
Anda tidak dapat memperbarui jenis VM standar ini. Jenis VM standar ini
diinstal ulang jika tidak ada di cluster setiap kali
vm-controller-manager dimulai atau dimulai ulang, seperti jika Anda menghapus jenis VM.
Membuat jenis VM
Anda dapat membuat jenis VM sendiri agar sesuai dengan kebutuhan komputasi workload Anda.
Buat manifes VirtualMachineType seperti my-vm-type.yaml, di
editor pilihan Anda:
Dalam file YAML ini, tentukan nama jenis VM kustom yang Anda buat di
bagian sebelumnya, seperti my-vm-type, sebagai nilai untuk
virtualMachineTypeName.
VM menghubungkan eth0 ke jaringan pod-network default.
Disk booting bernama VM_NAME-boot-dv harus sudah
ada. Untuk mengetahui informasi selengkapnya, lihat
Membuat dan mengelola disk virtual.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-31 UTC."],[],[],null,["This 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\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\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\nCLI\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\nManifest\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\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\nCreate 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\nCreate 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- [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)."]]