Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Anda dapat menghentikan, memulai, dan memulai ulang VM untuk mendukung siklus proses aplikasi Anda. Misalnya, Anda mungkin ingin mengubah jumlah unit pemrosesan terpusat virtual (vCPU) yang ditetapkan atau jumlah memori yang dialokasikan ke VM. Anda harus menghentikan VM sebelum mengedit konfigurasi. Setelah selesai,
Anda harus mengubah status daya untuk menerapkan perubahan. Halaman ini memberikan petunjuk
untuk menghentikan, memulai, dan memulai ulang VM Anda dalam proses tersebut.
Sebelum memulai
Untuk menggunakan perintah antarmuka command line (CLI) gdcloud, pastikan Anda telah mendownload, menginstal,
dan mengonfigurasi CLI gdcloud.
Semua perintah untuk Distributed Cloud menggunakan CLI gdcloud atau
kubectl, dan memerlukan lingkungan sistem operasi (OS).
Mendapatkan jalur file kubeconfig
Untuk menjalankan perintah terhadap server Management API, pastikan Anda memiliki resource berikut:
Login dan buat file kubeconfig untuk server Management API jika Anda belum memilikinya.
Gunakan jalur ke file kubeconfig server Management API untuk menggantikan
MANAGEMENT_API_SERVER dalam petunjuk ini.
Jika Anda ingin meminimalkan waktu mulai VM, ikuti petunjuk di bagian
Meminimalkan waktu mulai VM
sebelum Anda memulai VM.
Meminta izin dan akses
Untuk melakukan tugas yang tercantum di halaman ini, Anda harus memiliki peran Project VirtualMachine Admin. Ikuti langkah-langkah untuk
memverifikasi
atau meminta Admin IAM Project
memberi
Anda peran Project VirtualMachine Admin (project-vm-admin) di namespace
project tempat VM berada.
Untuk operasi VM menggunakan konsol GDC atau gdcloud CLI,
minta Admin IAM Project Anda untuk memberi Anda peran
Project VirtualMachine Admin dan peran Project Viewer (project-viewer).
Menghentikan VM
Saat Anda menghentikan virtual machine (VM), hypervisor akan membatalkan alokasi semua resource yang terkait dengan instance. VM dimatikan.
Hentikan VM yang dalam status berjalan menggunakan konsol GDC atau kubectl.
Konsol
Di menu navigasi, klik Virtual Machines > Instances.
Dalam daftar VM, centang kotak untuk VM yang sedang berjalan yang ingin Anda
hentikan.
Cari kolom runningState di spec VM dan ubah nilai kolom menjadi Stopped. Jika runningState tidak ada di spec, tambahkan runningState ke spec dan tetapkan nilai ke Stopped.
[[["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-09-04 UTC."],[[["\u003cp\u003eThis guide details how to manage the lifecycle of virtual machines (VMs) by stopping, starting, and restarting them to support application needs.\u003c/p\u003e\n"],["\u003cp\u003eYou can modify a VM's configuration, such as vCPU count or memory, but the VM must be stopped before these changes can be applied and then must be power cycled for them to take effect.\u003c/p\u003e\n"],["\u003cp\u003eThe process of stopping a VM involves deallocating all resources associated with the instance, whereas starting a VM returns it from a stopped state to running.\u003c/p\u003e\n"],["\u003cp\u003eRestarting a VM resets it to its initial state and wipes the memory contents, essentially rebooting the system.\u003c/p\u003e\n"],["\u003cp\u003eTo perform these operations, you will need the Project VirtualMachine Admin role and use either the GDC console, \u003ccode\u003egdcloud\u003c/code\u003e CLI, or \u003ccode\u003ekubectl\u003c/code\u003e CLI.\u003c/p\u003e\n"]]],[],null,["# Start and stop a VM\n\nYou can stop, start, and restart VMs to support the lifecycle of your\napplications. For example, you might want to change the number of assigned\nvirtual centralized processing units (vCPUs) or the amount of memory allocated to\na VM. You must stop the VM before you edit the configuration. After you finish,\nyou must cycle the power state to apply the changes. This page provides instructions\nto stop, start, and restart your VMs in such processes.\n\nBefore you begin\n----------------\n\nTo use `gdcloud` command-line interface (CLI) commands, ensure that you have downloaded, installed,\nand configured the [`gdcloud` CLI](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-overview).\nAll commands for Distributed Cloud use the `gdcloud` or\n`kubectl` CLI, and require an operating system (OS) environment.\n\n### Get the kubeconfig file path\n\nTo run commands against the Management API server, ensure you have the following\nresources:\n\n1. [Sign in and generate](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/sign-in#cli) the\n kubeconfig file for the Management API server if you don't have one.\n\n2. Use the path to the kubeconfig file of the Management API server to replace\n \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e in these instructions.\n\nIf you want to minimize your VM start up time, follow the directions in\n[Minimize the VM start time](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/manage-vms/operations-and-lifecycle/minimize-vm-start)\nbefore you start your VM.\n\n### Request permissions and access\n\nTo perform the tasks listed in this page, you must have the Project\nVirtualMachine Admin role. Follow the steps to either\n[verify](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation#verify-user-access)\nor have your Project IAM Admin\n[assign](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/role-bindings)\nyou the Project VirtualMachine Admin (`project-vm-admin`) role in the namespace\nof the project where the VM resides.\n\nFor VM operations using the GDC console or the gdcloud CLI,\nrequest your Project IAM Admin to assign you both the\nProject VirtualMachine Admin role and the Project Viewer (`project-viewer`)\nrole.xs\n\nStop a VM\n---------\n\nWhen you stop a virtual machine (VM), the hypervisor deallocates all resources\nassociated with the instance. The VM is shut down.\n\nStop a VM that's in a running state by using the GDC console or\n`kubectl`. \n\n### Console\n\n1. In the navigation menu, click **Virtual Machines \\\u003e Instances**.\n\n2. In the list of VMs, select the checkbox for the running VM that you want\n to stop.\n\n3. Click **Stop**.\n\n4. In the confirmation dialog, click **Stop**.\n\n### gdcloud\n\nTo stop a VM: \n\n gdcloud compute instances stop \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e --project \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n- Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM.\n- Replace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with the name of the GDC project in which the VM lives.\n\n### kubectl\n\n1. Run the following command:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n edit virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n2. Look for the field `runningState` in the `spec` of the VM and change the value of the field to `Stopped`. If `runningState` is not in the `spec` add `runningState` to the `spec` and set the value to `Stopped`.\n\n spec:\n runningState: Stopped\n\n3. Verify the status of the VM:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Use these definitions for the preceding variables.\n\nStart a VM\n----------\n\nStart a VM from a stopped state by using the console or `kubectl`. \n\n### Console\n\n1. In the navigation menu, click **Virtual Machines \\\u003e Instances**.\n\n2. In the list of VMs, select the checkbox for the stopped VM that you want\n to start.\n\n3. Click **Start**.\n\n4. In the confirmation dialog, click **Start**.\n\n### gdcloud\n\nTo start a VM: \n\n gdcloud compute instances start \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e --project \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n- Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM.\n- Replace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with the name of the GDC project in which the VM lives.\n\n### kubectl\n\n1. Run the following command:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\ \n edit virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\ \n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n2. Look for the field `runningState` in the `spec` of the VM and change the value of the field to `Running`.\n\n spec:\n runningState: Running\n\n3. Verify the VM status:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Use these definitions for the variables in the example code.\n\nRestart a VM\n------------\n\nWhen you restart a VM, the machine resets to its initial state and the memory\ncontents of the machine are wiped.\n\nRestart a VM that is in a running state by using the console or `kubectl`. \n\n### Console\n\n1. In the navigation menu, click **Virtual Machines \\\u003e Instances**.\n\n2. In the list of VMs, select the checkbox for the running VM that you want\n to restart.\n\n3. Click **Reset**.\n\n4. In the confirmation dialog, click **Reset**.\n\n### gdcloud\n\nTo reset a VM: \n\n gdcloud compute instances reset \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e --project \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n- Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM.\n- Replace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with the name of the GDC project in which the VM lives.\n\n### kubectl\n\n1. Get the client certificate and key data, and the Management API server.\n Use these values in the following steps:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e config view --raw -o \\\n jsonpath='{.users[?(@.name ==\"\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_NAME\u003c/var\u003e-admin\")].user.client-certificate-data}' | \\\n base64 -d \u003e cert\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e config view --raw -o \\\n jsonpath='{.users[?(@.name == \"\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_NAME\u003c/var\u003e-admin\")].user.client-key-data}' | \\\n base64 -d \u003e key\n export APISERVER=`kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n config view --raw -o \\\n jsonpath='{.clusters[?(@.name == \"\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_NAME\u003c/var\u003e\")].cluster.server}'`\n\n2. Make an API request to restart the VM using the `wget` command and specify\n the certificate and key from the previous step:\n\n wget --method=PUT -O- --no-check-certificate --certificate cert --private-key key --content-on-error=on $APISERVER/apis/virtualmachineoperations.gdc.goog/v1/namespaces/\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e/virtualmachines/\u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e/restart\n\n3. Verify the VM status:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Use these definitions for the variables in the\n example code."]]