Neste documento, apresentamos as técnicas de solução de problemas para implantações do Cloud Endpoints no Google Kubernetes Engine (GKE) e no Kubernetes.
Falha em kubectl create -f gke.yaml
Se você vir a mensagem de erro Failed in kubectl create -f gke.yaml, siga estas etapas:
Métricas e registros do Endpoints não são exibidos
Se você conseguir enviar solicitações para a API, mas não visualizar métricas ou registros na página Endpoints > Services no consoleGoogle Cloud , siga estas etapas:
Como acessar registros do Extensible Service Proxy
Se você precisar acessar os registros do Extensible Service Proxy (ESP) para diagnosticar problemas, use kubectl desta forma:
Consiga o nome do pod:
kubectl get pod
NAME READY STATUS RESTARTS AGE
esp-echo-174578890-x09gl 2/2 Running 2 21s
O nome do pod é esp-echo-174578890-x09gl e ele tem dois contêineres: esp e echo.
Para ver os registros em um pod, use kubectl logs:
kubectl logs POD_NAME -c CONTAINER_NAME
Em que POD_NAME e CONTAINER_NAME são retornados pelo comando kubectl get pod, na etapa anterior. Exemplo:
kubectl logs esp-echo-174578890-x09gl -c esp
Como verificar o nome do serviço
Caso a mensagem de erro Fetching service config failed seja exibida, verifique se o nome de serviço especificado no campo --service do arquivo de manifesto de implantação (chamado de arquivo deployment.yaml) corresponde ao nome do host na propriedade name especificada no arquivo YAML de configuração da API gRPC (chamado de arquivo api_config.yaml).
Se o arquivo deployment.yaml tiver o nome incorreto:
Abra o arquivo deployment.yaml e vá para a seção configurada para o contêiner do ESP. Exemplo:
Altere SERVICE_NAME para que corresponda ao nome do host especificado na propriedade name do arquivo api_config.yaml e salve o arquivo deployment.yaml.
Inicie o serviço do Kubernetes:
kubectl create -f deployment.yaml
Se o arquivo api_config.yaml tiver o nome incorreto:
Substitua SERVICE_NAME pelo nome da etapa anterior. O serviço é excluído do Google Cloudem 30 dias.
Não é possível reutilizar o nome do serviço durante esse período.
Abra o arquivo api_config.yaml e corrija o nome do host na propriedade name. Depois, salve o arquivo.
Aguarde até que a implantação da configuração do serviço seja concluída com sucesso.
Inicie o serviço do Kubernetes:
kubectl create -f deployment.yaml
Como verificar arquivos de configuração
Use ssh para se conectar ao pod usando kubectl:
kubectl exec -ti -c CONTAINER_NAMEPOD_NAME bash
Substitua CONTAINER_NAME pelo nome do
contêiner e POD_NAME pelo nome do pod.
No diretório etc/nginx/endpoints/, verifique se há erros nos seguintes arquivos de configuração:
nginx.conf- O arquivo de configuração nginx com diretivas ESP
service.jso - O arquivo de configuração do serviço
Como acessar a página de status do Endpoints
Se você definiu rollout_strategy como managed quando iniciou o ESP e precisa descobrir qual é o ID de configuração usado por uma instância do ESP, a página de status do Endpoints tem essas informações.
Veja como acessar a página de status do Endpoints:
Use ssh para se conectar ao pod usando kubectl:
kubectl exec -ti -c CONTAINER_NAMEPOD_NAME bash
Substitua CONTAINER_NAME pelo nome do contêiner e POD_NAME pelo nome do pod.
[[["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-04 UTC."],[[["\u003cp\u003eThis document provides troubleshooting steps for Endpoints deployments on Google Kubernetes Engine (GKE) and Kubernetes, addressing issues like failed \u003ccode\u003ekubectl create\u003c/code\u003e, missing metrics/logs, and incorrect service names.\u003c/p\u003e\n"],["\u003cp\u003eTo resolve the \u003ccode\u003eFailed in kubectl create -f gke.yaml\u003c/code\u003e error, users should authorize \u003ccode\u003egcloud\u003c/code\u003e, create a cluster using \u003ccode\u003egcloud\u003c/code\u003e or the Google Cloud console, and then obtain cluster credentials via \u003ccode\u003egcloud container clusters get-credentials\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIf Endpoints metrics and logs are not displayed, verify that all required services are enabled and the necessary permissions have been granted, as indicated in the documentation.\u003c/p\u003e\n"],["\u003cp\u003eTo access Extensible Service Proxy (ESP) logs, users can utilize \u003ccode\u003ekubectl logs\u003c/code\u003e along with the pod name and container name, obtained by first listing the pod name with the \u003ccode\u003ekubectl get pod\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eCorrecting service name discrepancies involves editing either the \u003ccode\u003edeployment.yaml\u003c/code\u003e or \u003ccode\u003eapi_config.yaml\u003c/code\u003e files, depending on the location of the incorrect name, and then redeploying, including deleting and recreating the service as needed.\u003c/p\u003e\n"]]],[],null,["# Troubleshooting Cloud Endpoints in GKE\n\n[OpenAPI](/endpoints/docs/openapi/troubleshoot-gke-deployment \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nThis document presents troubleshooting techniques for Endpoints\ndeployments on Google Kubernetes Engine (GKE) and Kubernetes.\n\nFailed in `kubectl create -f gke.yaml`\n--------------------------------------\n\nIf you see the `Failed in kubectl create -f gke.yaml` error message, take the\nfollowing steps:\n\n1. Authorize `gcloud`:\n\n gcloud auth login\n gcloud auth application-default login\n\n2. Create a cluster. You can either use the following `gcloud`command, or create\n a cluster using\n [Google Cloud console](https://console.cloud.google.com/kubernetes).\n\n ```\n gcloud container clusters create CLUSTER_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e with your cluster's name.\n3. Get credentials for your cluster and make them available to `kubectl`:\n\n ```\n gcloud container clusters get-credentials CLUSTER_NAME\n ```\n\nEndpoints metrics and logs aren't displayed\n-------------------------------------------\n\nIf you can successfully send requests to your API, but you don't see any\nmetrics or logs on the **Endpoints** \\\u003e **Services** page in the\nGoogle Cloud console, take the following steps:\n\n1. Check all the [required services](/endpoints/docs/openapi/get-started-kubernetes-engine#checking_required_services) are enabled.\n2. Check all the [required permissions](/endpoints/docs/openapi/get-started-kubernetes-engine#checking_required_permissions) are granted.\n\nAccessing logs from Extensible Service Proxy\n--------------------------------------------\n\nIf you need to access the Extensible Service Proxy (ESP) logs to diagnose\nproblems, use `kubectl` as follows:\n\n1. Get the name of the pod:\n\n kubectl get pod\n\n NAME READY STATUS RESTARTS AGE\n esp-echo-174578890-x09gl 2/2 Running 2 21s\n\n The pod name is `esp-echo-174578890-x09gl` and it has two containers: `esp`\n and `echo`.\n2. To view the logs in a pod use `kubectl logs`:\n\n ```\n kubectl logs POD_NAME -c CONTAINER_NAME\n ```\n\n Where `POD_NAME` and\n `CONTAINER_NAME` are returned from the\n `kubectl get pod`\n command, in the previous step. For example: \n\n kubectl logs esp-echo-174578890-x09gl -c esp\n\nVerifying the service name\n--------------------------\n\nIf you see the error message `Fetching service config failed`, verify that the service name that you specified in the `--service` field in your Deployment manifest file (referred to as the `deployment.yaml` file) matches the host name in the `name` property specified in your gRPC API configuration YAML file (referred to as the `api_config.yaml` file).\n\n\u003cbr /\u003e\n\n**If the incorrect name is in the `deployment.yaml` file**:\n\n1. Open the `deployment.yaml` file and go to the section configured for the\n ESP container. For example:\n\n ```\n containers:\n - name: esp\n image: gcr.io/endpoints-release/endpoints-runtime:1\n args: [\n \"--http_port=8081\",\n \"--backend=127.0.0.1:8080\",\n \"--service=SERVICE_NAME\",\n \"--rollout_strategy=managed\"\n ]\n \n ```\n\n Change \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e so that it matches the host name\n specified in the `name` property in the `api_config.yaml` file and save the\n `deployment.yaml` file.\n2. Start the Kubernetes service:\n\n kubectl create -f deployment.yaml\n\n**If the incorrect name is in the `api_config.yaml` file**:\n\n1. [Get the service name](/endpoints/docs/grpc/get-service-name-config-id)\n that Endpoints was configured to use.\n\n2. Delete the service:\n\n ```\n gcloud endpoints services delete SERVICE_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name from the previous\n step. It takes 30 days for the service to be deleted from Google Cloud.\n You aren't able to reuse the service name during this time.\n3. Open the `api_config.yaml` file and correct the host name in the\n `name` property and save the file.\n\n4. Deploy the updated service configuration:\n\n gcloud endpoints services deploy api_descriptor.pb api_config.yaml api_config_http.yaml\n\n Wait for the service configuration to be successfully deployed.\n5. Start the Kubernetes service:\n\n kubectl create -f deployment.yaml\n\nChecking configuration files\n----------------------------\n\n1. Use `ssh` to connect to the pod using `kubectl`:\n\n ```\n kubectl exec -ti -c CONTAINER_NAME POD_NAME bash\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name of your\n container and \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e with the name of your pod.\n2. In the `etc/nginx/endpoints/` directory, check the following configuration\n files for errors:\n\n - `nginx.conf`- The `nginx` config file with ESP directives\n - `service.jso` - The service configuration file\n\nAccessing the Endpoints status page\n-----------------------------------\n\nIf you set `rollout_strategy` to `managed` when you started ESP,\nand you need to find out the configuration ID that an instance of\nESP is using, the Endpoints status page has the information.\n\nTo access the Endpoints status page:\n\n1. Use `ssh` to connect to the pod using `kubectl`:\n\n ```\n kubectl exec -ti -c CONTAINER_NAME POD_NAME bash\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e with the name of your\n container and \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e with the name of your pod.\n2. Install [`curl`](https://curl.haxx.se/download.html).\n\n3. Enter the following:\n\n curl http://localhost:8090/endpoints_status\n\n It displays something similar the following: \n\n \"serviceConfigRollouts\": {\n \"rolloutId\": \"2017-08-09r27\",\n \"percentages\": {\n \"2017-08-09r26\": \"100\"\n }\n }\n\nThe value in the `rolloutId` is the service configuration ID that\nESP is using. To make sure that ESP is using the\nsame configuration as Endpoints,\nsee\n[Getting the service name and configuration ID](/endpoints/docs/grpc/get-service-name-config-id)."]]