gcloud-debug
Skill0 starsChanged 4 months agoMITView on GitHub
Diagnose common GCP failures on Cloud Run, GKE, and Cloud Functions. Use when the user reports a Cloud Run cold start, 500 or 503 responses, a revision that will not serve traffic, a GKE pod in CrashLoopBackOff or ImagePullBackOff, a Cloud Functions deployment error, or a Cloud Functions runtime error. Shows the exact gcloud commands to pull logs and metrics.
- Reads credentials
In this repository5 other files it gives its agents.
- cloud-run-deploySkill
- firestore-rulesSkill
- gke-manifestSkill
- iam-auditSkill
- terraform-gcpSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Before running any command, confirm the active project:
- Very specific: line 60
500 with "Container failed to start": read gcloud run revisions describe <revision> for the exit reason.
- Distinctive: line 127
If two causes are equally likely, list each with the one command that would confirm it.
- Very specific: line 155
Do not run destructive commands (gcloud run services delete, gcloud container clusters delete, gcloud functions delete, gcloud logging …
- Very specific: line 156
Do not print secret values from gcloud secrets versions access output or from environment variables that look like tokens.
- Distinctive: line 157
Do not guess. If logs do not show the cause, say which log filter or describe field would reveal it.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Diagnose GCP failures
Find the root cause of a Cloud Run, GKE, or Cloud Functions failure and suggest a concrete fix.
Inputs
$ARGUMENTS is optional context: a service name, a revision id, a pod name and namespace, a function name, and the region. If empty, ask the user which resource is failing and in which region and project.
Before running any command, confirm the active project:
gcloud projects describe $(gcloud config get-value project)Detection steps
Cloud Run: cold start or 5xx responses
- Describe the service to see the active revision, min and max instances, and concurrency:
gcloud run services describe <service> --region <region> --format yaml- List recent revisions and find the one serving traffic:
gcloud run revisions list --service <service> --region <region> --limit 10- Pull the last 15 minutes of request logs and filter for 5xx:
gcloud logging read 'resource.type="cloud_run_revision"
resource.labels.service_name="<service>"
httpRequest.status>=500' \
--limit 100 --freshness 15m --format json- Pull stderr for the revision (this is where unhandled exceptions go):
gcloud logging read 'resource.type="cloud_run_revision"
resource.labels.service_name="<service>"
severity>=ERROR' \
--limit 100 --freshness 15m- Common Cloud Run failures and what to check:
- Cold start timeouts: the container takes more than the startup probe allows. Set
minScale: 1to keep one instance warm, or increase the container startup timeout with--cpu-boostand--startup-cpu-boost. - 502 with no stderr: the container is not listening on
$PORT. Cloud Run injectsPORT(defaults to 8080). The app must bind to0.0.0.0:$PORT, not tolocalhostor a hard-coded port. - 503 "no available instances":
maxScaleis reached. Raise it, reduce concurrency, or fix a memory leak that prevents instances from recycling. - 500 with "Container failed to start": read
gcloud run revisions describe <revision>for the exit reason. Typical causes are a crash before listening on$PORT, a missing env var, or an IAM denial reaching Secret Manager. - Permission denied reaching a GCP API: the runtime service account lacks the role. Do not use the default compute service account. Create a dedicated service account and grant only the roles needed.
- Cold start timeouts: the container takes more than the startup probe allows. Set
GKE: pod errors
- Describe the cluster to confirm you are pointed at the right one:
gcloud container clusters describe <cluster> --region <region>- Pull pod state through the GKE control plane logs (no kubeconfig needed):
gcloud logging read 'resource.type="k8s_pod"
resource.labels.cluster_name="<cluster>"
resource.labels.namespace_name="<ns>"
resource.labels.pod_name="<pod>"' \
--limit 100 --freshness 30m- Pull container stderr:
gcloud logging read 'resource.type="k8s_container"
resource.labels.cluster_name="<cluster>"
resource.labels.pod_name="<pod>"
severity>=ERROR' \
--limit 100 --freshness 30m- Common GKE failures and what to check:
- ImagePullBackOff from Artifact Registry: either the image tag is wrong, or the node pool service account lacks
roles/artifactregistry.readeron the repo's project. Grant the role on the repo, not on the whole project. - CrashLoopBackOff with exit 137: OOMKilled. Raise the memory limit. On Autopilot, the request equals the limit, so raise
resources.requests.memory. - Workload Identity denial: the Kubernetes service account is not annotated with
iam.gke.io/gcp-service-account, or the GCP service account does not haveroles/iam.workloadIdentityUserfor the KSA. Check both sides. - LoadBalancer stuck in
Pending: the VPC-native cluster needs a reserved external IP, or a firewall rule blocks the health check from130.211.0.0/22and35.191.0.0/16. - BackendConfig not applied: the Service is missing the annotation
cloud.google.com/backend-config, or the BackendConfig name is wrong.
- ImagePullBackOff from Artifact Registry: either the image tag is wrong, or the node pool service account lacks
Cloud Functions: deploy or runtime error
- Describe the function to see the runtime, entry point, and last revision:
gcloud functions describe <function> --region <region> --gen2- Pull build logs (deploy failures) and runtime logs (500s):
gcloud logging read 'resource.type="cloud_function"
resource.labels.function_name="<function>"
severity>=WARNING' \
--limit 100 --freshness 30m- Common Cloud Functions failures and what to check:
- Deployment fails with "Container Healthcheck failed": the code does not start a server or does not export the expected entry point. For gen2 HTTP functions, the function must respond within the configured startup time and the entry point name must match the export.
- Deployment fails with permission denied on Cloud Build or Artifact Registry: the Cloud Build service account
<project-number>@cloudbuild.gserviceaccount.comneedsroles/artifactregistry.writeron the function's image repo. Gen2 uses Artifact Registry, not Container Registry. - Runtime 500 with no error in logs: the function timed out. Raise
--timeout(max 540s for gen1, 3600s for gen2 HTTP) or move long work to a Pub/Sub triggered function with retries. - "ENOMEM" or "out of memory": raise
--memory. Defaults are low. - Event was not delivered: the Eventarc trigger's service account is missing
roles/eventarc.eventReceiveror the Pub/Sub subscription has piled up unacked messages. Check the subscription backlog.
Output
- State the single most likely root cause in one short sentence.
- Show the 3 to 10 lines of log output that prove it. Never paste secret values.
- Give the concrete fix. If the fix is a gcloud command, show the full command with the flags needed.
- If two causes are equally likely, list each with the one command that would confirm it.
Example diagnosis
Root cause: the Cloud Run revision crashes on startup because the container is listening on port 3000 but Cloud Run sets PORT=8080.
Evidence:
resource.labels.service_name="api"
textPayload: "listening on http://0.0.0.0:3000"
... (no logs for /healthz from the load balancer)
revision status: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.Fix: bind to process.env.PORT || 8080 in the app, or set --port 3000 on the service if the app cannot be changed:
gcloud run services update api --region us-central1 --port 3000Next step:
gcloud run revisions list --service api --region us-central1 --limit 3
gcloud logging read 'resource.labels.service_name="api" severity>=ERROR' --limit 20 --freshness 5mDo not
- Do not run destructive commands (
gcloud run services delete,gcloud container clusters delete,gcloud functions delete,gcloud logging sinks delete) without asking the user first. - Do not print secret values from
gcloud secrets versions accessoutput or from environment variables that look like tokens. - Do not guess. If logs do not show the cause, say which log filter or describe field would reveal it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

