Melihat detail VM


Dokumen ini menjelaskan cara melihat detail instance virtual machine (VM) yang ada.

Melihat detail VM berguna untuk melihat konfigurasi dan statusnya, seperti disk yang terpasang, stempel waktu pembuatan, jenis mesin, dan ID VM—yang dapat Anda gunakan untuk mereferensikan VM menggunakan nilai yang tidak dapat diubah.

Sebelum memulai

  • Jika Anda belum melakukannya, siapkan autentikasi. Autentikasi adalah proses di mana identitas Anda diverifikasi untuk mengakses layanan dan API Google Cloud. Untuk menjalankan kode atau sampel dari lingkungan pengembangan lokal, Anda dapat melakukan autentikasi ke Compute Engine sebagai berikut.

    Pilih tab untuk melihat bagaimana Anda berencana menggunakan contoh di halaman ini:

    Konsol

    Saat menggunakan Konsol Google Cloud untuk mengakses API dan layanan Google Cloud, Anda tidak perlu menyiapkan autentikasi.

    gcloud

    1. Instal Google Cloud CLI, lalu initialize dengan menjalankan perintah berikut:

      gcloud init
    2. Menetapkan region dan zona default.

    REST

    Untuk menggunakan contoh REST API di halaman ini dalam lingkungan pengembangan lokal, gunakan kredensial yang Anda berikan ke gcloud CLI.

      Instal Google Cloud CLI, lalu initialize dengan menjalankan perintah berikut:

      gcloud init

Peran yang diperlukan

Untuk mendapatkan izin yang Anda perlukan guna melihat detail VM, minta administrator untuk memberi Anda peran IAM Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) di VM atau project. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses.

Peran bawaan ini berisi izin compute.instances.get, yang diperlukan untuk melihat detail VM.

Anda mungkin juga bisa mendapatkan izin ini dengan peran khusus atau peran bawaan lainnya.

Melihat detail VM

Untuk melihat detail VM, pilih salah satu opsi berikut:

Konsol

  1. Di konsol Google Cloud, buka halaman Instance VM.

    Buka instance VM

  2. Di halaman VM instances, Anda dapat melihat informasi berikut untuk instance compute:

    • Nama instance.
    • Zona tempat instance berada.
    • Jenis mesin yang digunakan oleh instance.
    • Model penyediaan, yang menunjukkan apakah instance dibuat sebagai Spot VM.
    • Rekomendasi apa pun yang tersedia untuk instance tersebut.
    • Apakah instance VM merupakan bagian dari grup instance.
    • Alamat IP yang digunakan oleh instance.

    Daftar sebelumnya berisi kolom default yang ditampilkan di halaman VM instances. Anda dapat mengklik Opsi tampilan kolom untuk mengubah kolom yang ditampilkan untuk setiap VM.

  3. Di kolom Name, klik nama VM untuk melihat detail tambahan tentang instance VM.

gcloud

Untuk melihat detail VM, gunakan perintah gcloud compute instances describe.

gcloud compute instances describe VM_NAME \
    --zone=ZONE

Ganti kode berikut:

  • VM_NAME: nama VM.

  • ZONE: zona tempat VM berada.

Outputnya mirip dengan hal berikut ini:

canIpForward: false
confidentialInstanceConfig:
  enableConfidentialCompute: false
cpuPlatform: Intel Broadwell
creationTimestamp: '2023-08-18T10:00:21.801-07:00'
deletionProtection: false
description: ''
disks:
- architecture: X86_64
  autoDelete: true
  boot: true
  deviceName: example-vm
  diskSizeGb: '10'
  guestOsFeatures:
  - type: UEFI_COMPATIBLE
  - type: VIRTIO_SCSI_MULTIQUEUE
  - type: GVNIC
  - type: SEV_CAPABLE
  index: 0
  interface: SCSI
  kind: compute#attachedDisk
  licenses:
  - https://www.googleapis.com/compute/v1/projects/debian-cloud/global/licenses/debian-11-bullseye
  mode: READ_WRITE
  source: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/disks/example-vm
  type: PERSISTENT
displayDevice:
  enableDisplay: false
fingerprint: CQp-QBEACqw=
id: '6404261768674286922'
keyRevocationActionType: NONE
kind: compute#instance
labelFingerprint: 42WmSpB8rSM=
lastStartTimestamp: '2023-08-18T10:00:28.182-07:00'
machineType: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/machineTypes/e2-medium
metadata:
  fingerprint: lQ-dD2sMrMY=
  items:
  - key: enable-oslogin
    value: 'true'
  kind: compute#metadata
name: example-vm
networkInterfaces:
- accessConfigs:
  - kind: compute#accessConfig
    name: External NAT
    natIP: 34.27.53.198
    networkTier: PREMIUM
    type: ONE_TO_ONE_NAT
  fingerprint: QR3z6TgVFjg=
  kind: compute#networkInterface
  name: nic0
  network: https://www.googleapis.com/compute/v1/projects/example-project/global/networks/default
  networkIP: 10.128.0.28
  stackType: IPV4_ONLY
  subnetwork: https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/subnetworks/default
reservationAffinity:
  consumeReservationType: ANY_RESERVATION
scheduling:
  automaticRestart: true
  onHostMaintenance: MIGRATE
  preemptible: false
  provisioningModel: STANDARD
selfLink: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances/example-vm
serviceAccounts:
- email: 790569220780-compute@developer.gserviceaccount.com
  scopes:
  - https://www.googleapis.com/auth/devstorage.read_only
  - https://www.googleapis.com/auth/logging.write
  - https://www.googleapis.com/auth/monitoring.write
  - https://www.googleapis.com/auth/servicecontrol
  - https://www.googleapis.com/auth/service.management.readonly
  - https://www.googleapis.com/auth/trace.append
shieldedInstanceConfig:
  enableIntegrityMonitoring: true
  enableSecureBoot: false
  enableVtpm: true
shieldedInstanceIntegrityPolicy:
  updateAutoLearnPolicy: true
startRestricted: false
status: RUNNING
tags:
  fingerprint: 42WmSpB8rSM=
zone: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a

REST

Untuk melihat detail VM, buat permintaan GET ke metode instances.get.

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME

Ganti kode berikut:

  • PROJECT_ID: ID project tempat VM berada.

  • ZONE: zona tempat VM berada.

  • VM_NAME: nama VM.

Outputnya mirip dengan hal berikut ini:

{
  "canIpForward": false,
  "confidentialInstanceConfig": {
    "enableConfidentialCompute": false
  },
  "cpuPlatform": "Intel Broadwell",
  "creationTimestamp": "2023-08-18T10:00:21.801-07:00",
  "deletionProtection": false,
  "description": "",
  "disks": [
    {
      "architecture": "X86_64",
      "autoDelete": true,
      "boot": true,
      "deviceName": "example-vm",
      "diskSizeGb": "10",
      "guestOsFeatures": [
        {
          "type": "UEFI_COMPATIBLE"
        },
        {
          "type": "VIRTIO_SCSI_MULTIQUEUE"
        },
        {
          "type": "GVNIC"
        },
        {
          "type": "SEV_CAPABLE"
        }
      ],
      "index": 0,
      "interface": "SCSI",
      "kind": "compute#attachedDisk",
      "licenses": [
        "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/licenses/debian-11-bullseye"
      ],
      "mode": "READ_WRITE",
      "source": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/disks/example-vm",
      "type": "PERSISTENT"
    }
  ],
  "displayDevice": {
    "enableDisplay": false
  },
  "fingerprint": "CQp-QBEACqw=",
  "id": "6404261768674286922",
  "keyRevocationActionType": "NONE",
  "kind": "compute#instance",
  "labelFingerprint": "42WmSpB8rSM=",
  "lastStartTimestamp": "2023-08-18T10:00:28.182-07:00",
  "machineType": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/machineTypes/e2-medium",
  "metadata": {
    "fingerprint": "lQ-dD2sMrMY=",
    "items": [
      {
        "key": "enable-oslogin",
        "value": "true"
      }
    ],
    "kind": "compute#metadata"
  },
  "name": "example-vm",
  "networkInterfaces": [
    {
      "accessConfigs": [
        {
        "kind": "compute#accessConfig",
        "name": "External NAT",
        "natIP": "34.27.53.198",
        "networkTier": "PREMIUM",
        "type": "ONE_TO_ONE_NAT"
        }
      ],
      "fingerprint": "QR3z6TgVFjg=",
      "kind": "compute#networkInterface",
      "name": "nic0",
      "network": "https://www.googleapis.com/compute/v1/projects/example-project/global/networks/default",
      "networkIP": "10.128.0.28",
      "stackType": "IPV4_ONLY",
      "subnetwork": "https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/subnetworks/default"
    }
  ],
  "reservationAffinity": {
    "consumeReservationType": "ANY_RESERVATION"
  },
  "scheduling": {
    "automaticRestart": true,
    "onHostMaintenance": "MIGRATE",
    "preemptible": false,
    "provisioningModel": "STANDARD"
  },
  "selfLink": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances/example-vm",
  "serviceAccounts": [
    {
    "email": "790569220780-compute@developer.gserviceaccount.com",
    "scopes": [
        "https://www.googleapis.com/auth/devstorage.read_only",
        "https://www.googleapis.com/auth/logging.write",
        "https://www.googleapis.com/auth/monitoring.write",
        "https://www.googleapis.com/auth/servicecontrol",
        "https://www.googleapis.com/auth/service.management.readonly",
        "https://www.googleapis.com/auth/trace.append"
      ]
    }
  ],
  "shieldedInstanceConfig": {
    "enableIntegrityMonitoring": true,
    "enableSecureBoot": false,
    "enableVtpm": true
  },
  "shieldedInstanceIntegrityPolicy": {
    "updateAutoLearnPolicy": true
  },
  "startRestricted": false,
  "status": "RUNNING",
  "tags": {
    "fingerprint": "42WmSpB8rSM="
  },
  "zone": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a"
}

Menentukan alokasi CPU dan memori untuk sebuah instance

Jumlah CPU dan memori yang dialokasikan ke instance komputasi dapat ditentukan dari jenis mesin yang digunakan oleh instance, misalnya:

  • c3-standard-22: C3 adalah nama seri mesin, standard adalah jenis alokasi memori untuk instance, dan 22 adalah jumlah vCPU yang dialokasikan ke instance. Biasanya, jenis mesin standard menggunakan rasio memori sebesar 4 GB per vCPU. Jadi, jenis mesin ini akan memiliki RAM 88 GB.

    Rasio memori terhadap CPU untuk jenis mesin standard, highmem, highcpu, ultamem, dan megamem dapat sedikit berbeda untuk setiap seri mesin. Jadi, lihat halaman seri mesin untuk menentukan jumlah persis memori yang dialokasikan untuk setiap jenis mesin.

  • n2-custom-8-16384: Untuk jenis mesin kustom, bagian pertama dari jenis mesin adalah seri mesin, kecuali untuk jenis mesin N1 yang tidak mencakup seri mesin sama sekali. Angka pertama setelah custom adalah jumlah vCPU, dan angka terakhir adalah jumlah memori (dalam MB) yang dialokasikan ke instance.

Untuk mengetahui informasi selengkapnya tentang jenis mesin, lihat Panduan perbandingan dan referensi kelompok mesin.

Langkah selanjutnya