Esta página é destinada a administradores de cluster que têm cargas de trabalho sensíveis ao desempenho e querem examinar a execução da CPU dessas cargas nos nós do GKE durante o desenvolvimento, a depuração, a comparativa e o monitoramento contínuo.
Antes de começar
Antes de começar, verifique se você realizou as tarefas a seguir:
Se você quiser usar a CLI do Google Cloud para essa tarefa,
instale e inicialize a
gcloud CLI. Se você instalou a gcloud CLI anteriormente, instale a versão
mais recente executando gcloud components update.
Requisitos e limitações
Ao ativar eventos de PMU, esteja ciente dos seguintes requisitos e limitações:
O cluster precisa estar no modo padrão.
Se o cluster tiver o provisionamento automático de nós ativado, nenhum pool de nós criado
por esse recurso poderá ativar eventos de PMU. Se você ativar o provisionamento automático de nós depois de ativar os eventos de PMU, os pools de nós atuais não serão afetados.
Os pools de nós do cluster precisam executar o tipo de máquina C4 ou C4A.
Criar um cluster do GKE
Crie um cluster com eventos de PMU ativados para o pool de nós padrão:
PMU_LEVEL: o tipo de eventos de PMU a serem coletados. Para mais informações, consulte Como a PMU funciona na documentação do Compute Engine. Os valores aceitos são:
architectural: ativa eventos de PMU arquitetural relacionados a eventos de cache não de último nível (LLC).
standard: inclui eventos arquitetônicos e ativa eventos de PMU principais,
incluindo eventos de cache L2.
enhanced: inclui eventos padrão e permite eventos locais fora do núcleo da CPU e eventos de PMU de LLC. Essa opção só está disponível para VMs com um número específico de vCPUs. Para mais informações, consulte Limitações na documentação do Compute Engine.
MACHINE_TYPE: o tipo de máquina do Compute Engine
para os nós. Para uma lista de tipos de máquina compatíveis, consulte as limitações na documentação do Compute Engine.
Verifique se os nós do cluster têm a PMU ativada examinando as mensagens do kernel.
Confira uma lista de nós no cluster:
kubectlgetnodes
O resultado será assim:
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
Anote o nome de um dos nós.
Confira o local do Compute Engine do nó:
gcloudcomputeinstanceslist--filter=NODE_NAME
Substitua NODE_NAME pelo nome de um nó da etapa anterior.
O resultado será assim:
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
Registre o nome da ZONE do Compute Engine. Neste exemplo, é
us-central1-c.
Use o SSH para se conectar ao nó do cluster:
gcloudcomputesshNODE_NAME\--zone=COMPUTE_ZONE
Substitua COMPUTE_ZONE pelo nome da zona do Compute Engine da etapa anterior.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-01 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)"]]