Halaman ini menunjukkan cara menganalisis performa CPU node cluster Google Kubernetes Engine (GKE) menggunakan peristiwa Unit Pemantauan Performa (PMU).
Halaman ini ditujukan untuk admin cluster yang memiliki workload yang sensitif terhadap performa dan ingin memeriksa eksekusi CPU workload mereka di node GKE selama pengembangan, proses debug, tolok ukur, dan pemantauan berkelanjutan.
Sebelum memulai
Sebelum memulai, pastikan Anda telah menjalankan tugas berikut:
Jika ingin menggunakan Google Cloud CLI untuk tugas ini,
instal lalu
lakukan inisialisasi
gcloud CLI. Jika sebelumnya Anda telah menginstal gcloud CLI, dapatkan versi terbaru dengan menjalankan gcloud components update.
Persyaratan dan batasan
Saat mengaktifkan peristiwa PMU, perhatikan persyaratan dan batasan berikut:
Cluster Anda harus dalam mode Standard.
Jika cluster Anda mengaktifkan penyediaan otomatis node, node pool yang dibuat melalui penyediaan otomatis tidak dapat mengaktifkan peristiwa PMU. Jika Anda mengaktifkan penyediaan otomatis node setelah mengaktifkan peristiwa PMU, node pool yang ada tidak akan terpengaruh.
Node pool cluster harus menjalankan jenis mesin C4 atau C4A.
Membuat cluster GKE
Buat cluster dengan peristiwa PMU yang diaktifkan untuk node pool default:
PMU_LEVEL: jenis peristiwa PMU yang akan dikumpulkan. Untuk mengetahui
informasi selengkapnya, lihat Cara kerja PMU
dalam dokumentasi Compute Engine. Nilai yang didukung adalah sebagai berikut:
architectural: mengaktifkan peristiwa PMU arsitektur yang terkait dengan peristiwa cache non-level terakhir (LLC).
standard: mencakup peristiwa arsitektur dan memungkinkan peristiwa PMU inti,
termasuk peristiwa cache L2.
enhanced: mencakup peristiwa standar dan memungkinkan peristiwa lokal di luar peristiwa PMU CPU core dan LLC. Opsi ini hanya tersedia dengan VM yang memiliki jumlah vCPU tertentu. Untuk mengetahui informasi selengkapnya, lihat
Batasan dalam
dokumentasi Compute Engine.
MACHINE_TYPE: jenis mesin Compute Engine untuk
node Anda. Untuk mengetahui daftar jenis mesin yang didukung, lihat
batasan dalam
dokumentasi Compute Engine.
Pastikan node cluster Anda mengaktifkan PMU dengan memeriksa pesan kernel.
Dapatkan daftar node di cluster:
kubectlgetnodes
Outputnya mirip dengan hal berikut ini:
NAME STATUS ROLES AGE VERSION
gke-c1-default-pool-44be3e13-prr1 Ready <none> 5d23h v1.27.13-gke.1070000
gke-c1-default-pool-7abc4a17-9dlg Ready <none> 2d21h v1.27.13-gke.1070000
gke-c1-default-pool-ed969ef6-4gzp Ready <none> 5d v1.27.13-gke.1070000
Catat nama salah satu node.
Dapatkan lokasi Compute Engine dari node:
gcloudcomputeinstanceslist--filter=NODE_NAME
Ganti NODE_NAME dengan nama node dari
langkah sebelumnya.
Outputnya mirip dengan hal berikut ini:
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-c1-default-pool-44be3e13-prr1 us-central1-c c4-standard-4 true 10.128.0.67 34.170.44.164 RUNNING
Catat nama ZONE Compute Engine. Dalam contoh ini, nilainya adalah
us-central1-c.
Gunakan SSH untuk terhubung ke node cluster:
gcloudcomputesshNODE_NAME\--zone=COMPUTE_ZONE
Ganti COMPUTE_ZONE dengan nama zona Compute Engine dari langkah sebelumnya.
[[["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-14 UTC."],[],[],null,["# Analyze CPU performance using the PMU\n\n[Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page shows you how to analyze the CPU performance of your\nGoogle Kubernetes Engine (GKE) cluster nodes using\n[Performance Monitoring Unit (PMU)](/compute/docs/pmu-overview) events.\n\nThis page is intended for cluster admins who have performance-sensitive\nworkloads and want to examine the CPU execution of their workloads on their\nGKE nodes during development, debugging, benchmarking, and\ncontinuous monitoring.\n\nBefore you begin\n----------------\n\nBefore you start, make sure that you have performed the following tasks:\n\n- Enable the Google Kubernetes Engine API.\n[Enable Google Kubernetes Engine API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n- If you want to use the Google Cloud CLI for this task, [install](/sdk/docs/install) and then [initialize](/sdk/docs/initializing) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running `gcloud components update`. **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](/sdk/docs/properties#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.\n\n### Requirements and limitations\n\nWhen enabling PMU events, be aware of the following requirements and limitations:\n\n- Your cluster must be Standard mode.\n- If your cluster has node auto-provisioning enabled, any node pools created through auto-provisioning cannot enable PMU events. If you enable node auto provisioning after enabling PMU events, existing node pools are not impacted.\n- Cluster node pools must run a machine series that supports PMU. For more information about the supported machine types, see the [PMU limitations table](/compute/docs/pmu-overview#limitations).\n\nCreate a GKE cluster\n--------------------\n\nCreate a cluster with PMU events enabled for the default node pool: \n\n gcloud container clusters create \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --location=\u003cvar translate=\"no\"\u003eCOMPUTE_LOCATION\u003c/var\u003e \\\n --performance-monitoring-unit=\u003cvar translate=\"no\"\u003ePMU_LEVEL\u003c/var\u003e \\\n --machine-type=\u003cvar translate=\"no\"\u003eMACHINE_TYPE\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of the new cluster.\n- \u003cvar translate=\"no\"\u003eCOMPUTE_LOCATION\u003c/var\u003e: the [Compute Engine location](/compute/docs/regions-zones#available) for the new cluster.\n- \u003cvar translate=\"no\"\u003ePMU_LEVEL\u003c/var\u003e: the type of PMU events to collect. For more information, see [How the PMU works](/compute/docs/pmu-overview#how-pmu-works) in the Compute Engine documentation. Supported values are as follows:\n - `architectural`: enables architectural PMU events related to non-last-level cache (LLC) events.\n - `standard`: includes architectural events and enables core PMU events, including L2 cache events.\n - `enhanced`: includes standard events and enables any local events outside the CPU core and LLC PMU events. This option is only available with VMs that have a specific number of vCPUs. For more information, see [Limitations](/compute/docs/pmu-overview#limitations) in the Compute Engine documentation.\n- \u003cvar translate=\"no\"\u003eMACHINE_TYPE\u003c/var\u003e: the Compute Engine machine type for your nodes. For a list of supported machine types, see [limitations](/compute/docs/pmu-overview#limitations) in the Compute Engine documentation.\n\nYou can also create a new node pool for an existing cluster using the\n[`gcloud container node-pools create`](/sdk/gcloud/reference/container/node-pools/create)\ncommand.\n\nConnect to the cluster\n----------------------\n\nConfigure `kubectl` to communicate with the cluster: \n\n gcloud container clusters get-credentials \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --location=\u003cvar translate=\"no\"\u003eCOMPUTE_LOCATION\u003c/var\u003e\n\nVerify the PMU is enabled\n-------------------------\n\nVerify your cluster nodes have PMU enabled by examining the kernel messages.\n\n1. Get a list of nodes in the cluster:\n\n kubectl get nodes\n\n The output is similar to the following: \n\n NAME STATUS ROLES AGE VERSION\n gke-c1-default-pool-44be3e13-prr1 Ready \u003cnone\u003e 5d23h v1.27.13-gke.1070000\n gke-c1-default-pool-7abc4a17-9dlg Ready \u003cnone\u003e 2d21h v1.27.13-gke.1070000\n gke-c1-default-pool-ed969ef6-4gzp Ready \u003cnone\u003e 5d v1.27.13-gke.1070000\n\n Record the name of one of the nodes.\n2. Get the Compute Engine location of the node:\n\n gcloud compute instances list --filter=\u003cvar translate=\"no\"\u003eNODE_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eNODE_NAME\u003c/var\u003e with the name of a node from\n the previous step.\n\n The output is similar to the following: \n\n NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS\n gke-c1-default-pool-44be3e13-prr1 us-central1-c c4-standard-4 true 10.128.0.67 34.170.44.164 RUNNING\n\n Record the name of the Compute Engine `ZONE`. In this example, it's\n `us-central1-c`.\n3. Use SSH to connect to the cluster node:\n\n gcloud compute ssh \u003cvar translate=\"no\"\u003eNODE_NAME\u003c/var\u003e \\\n --zone=\u003cvar translate=\"no\"\u003eCOMPUTE_ZONE\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eCOMPUTE_ZONE\u003c/var\u003e with the name of the\n Compute Engine zone from the previous step.\n4. Examine the kernel messages:\n\n sudo dmesg |grep -A10 -i \"Performance\"\n\n The output is similar to the following: \n\n [ 0.307634] Performance Events: generic architected perfmon, full-\n width counters, Intel PMU driver.\n # Several lines omitted\n\n This output indicates the PMU driver is initialized.\n\nWhat's next\n-----------\n\n- Learn how to [Choose a minimum CPU platform](/kubernetes-engine/docs/how-to/min-cpu-platform)"]]