AGENT SKILL

pod-crashloop-oom

Finds why a named pod or workload keeps restarting. Use for CrashLoopBackOff, Error, OOMKilled or exit code 137, a non-zero exit code, failing liveness or readiness probes (NotReady), Evicted or Failed pods, and high restart counts on one workload. Reads the last termination, previous logs and limits, and proposes the manifest fix.

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 126
Forks
44

01 前言 Front Matter

name
pod-crashloop-oom
description
Finds why a named pod or workload keeps restarting. Use for CrashLoopBackOff, Error, OOMKilled or exit code 137, a non-zero exit code, failing liveness or readiness probes (NotReady), Evicted or Failed pods, and high restart counts on one workload. Reads the last termination, previous logs and limits, and proposes the manifest fix.

03 SKILL.md 正文

Task

Name the cause of one workload's restarts, quote the evidence, and propose the manifest patch. Investigate one representative pod: replicas of one controller share a cause.

Workflow

  1. Read the container state, limits, probes, command and owner in one projected call:

    kubectl get pod <pod> -n <namespace> -o json | jq '{owner: .metadata.ownerReferences, node: .spec.nodeName, initContainers: [.spec.initContainers[]? | {name, image, command, args, resources, env: [.env[]? | {name, valueFrom}], envFrom}], containers: [.spec.containers[] | {name, image, command, args, resources, env: [.env[]? | {name, valueFrom}], envFrom, livenessProbe, readinessProbe}], initStatus: [.status.initContainerStatuses[]? | {name, ready, restartCount, state, lastState}], status: [.status.containerStatuses[]? | {name, ready, restartCount, state, lastState}], reason: .status.reason, message: .status.message}'
    
  2. Read the previous container's log tail, or pass -c <container> without -p when step 1 shows restartCount: 0 (or -c <init-container> -p when an init container is restarting while app containers wait in PodInitializing):

    kubectl logs <pod> -n <namespace> --all-containers -p --tail=50
    
  3. Read this pod's events only:

    kubectl get events -n <namespace> --field-selector involvedObject.name=<pod> -o custom-columns=LAST:.lastTimestamp,TYPE:.type,REASON:.reason,COUNT:.count,MESSAGE:.message
    

    Events last about an hour. For a failure reported as earlier ("since this morning"), read the window from Cloud Logging instead, centred on the last finishedAt from step 1 (30 minutes either side):

    gcloud logging read "resource.type=\"k8s_cluster\" AND logName=\"projects/<project_id>/logs/events\" AND jsonPayload.involvedObject.namespace=\"<namespace>\" AND timestamp>=\"<start_time>\" AND timestamp<=\"<end_time>\"" --project=<project_id> --limit=50 --format="table(timestamp,jsonPayload.reason,jsonPayload.message)"
    
  4. Match the evidence, then record the finding as workload-triage-scan/references/reporting.md describes. Stop once the cause, the evidence and the patch are written.

Signatures

Evidence Cause Patch
exitCode: 137, reason: OOMKilled Memory limit reached Raise resources.limits.memory, or fix the leak the log and command show
exitCode: 1 or another non-zero code, stack trace in the log Application crash Name the exception; propose the config or image fix it points to
Log names a missing variable, password, file or key Missing configuration Add the env, envFrom or Secret/ConfigMap reference
Read-only file system or Permission denied on /tmp, /var readOnlyRootFilesystem with no scratch Mount an emptyDir at that path
Liveness probe failed or Readiness probe failed events Probe path, port or timing wrong Correct the probe, or raise initialDelaySeconds
Connection timed out, dial tcp: i/o timeout in the log Dependency unreachable Load service-connectivity for the target service
reason: Evicted, node pressure message Node memory or disk pressure Set requests near real usage; check the node in the message
exitCode: 143 with no other error SIGTERM: stopped by the kubelet or a probe Read the probe events; extend terminationGracePeriodSeconds if needed

For an OOM, tell an application leak or loop (unbounded growth in the log, a command that loads everything into memory) from a limit set below real demand. When a GKE event reason or exit code is unfamiliar, search the developer_knowledge MCP server's tools before a web search.

Rules

  • Budget about five commands. Do not describe or log every replica.
  • A pod under the scan's 10-minute startup grace period (Running not Ready or PodInitializing while under 10 minutes old with restartCount: 0 and no non-zero container termination in the last 60 minutes) is initializing: report it with no proposed patch, do not wait.
  • Never sleep or --watch for the next restart.

04 同仓库更多 Skills

gke-labs
gke-labs/kube-agents

gke-workload-troubleshooting

Diagnoses GKE workload failures (CrashLoopBackOff, OOMKilled, ImagePullBackOff, Pending, etc.) via logs and events. Use when pods fail to start or crash repeatedly. Don't use for GKE cluster infrastructure provisioning, node pool creation, or non-Kubernetes Google Cloud services.

★ 126
gke-labs
gke-labs/kube-agents

gke-workload-security

Audits, configures, and hardens workload-level security controls for Google Kubernetes Engine (GKE) applications and namespaces. Covers running security audits (`audit_cluster.sh`), enforcing Network Policies (default-deny and Dataplane V2 logging), isolating high-risk pods inside GKE Sandbox (`gVisor`), enforcing Pod Security Standards (`restricted` labeling) and pod securityContext, and mounting Secret Manager secrets via CSI (`SecretProviderClass`). Use when auditing workload security posture, isolating namespaces, applying pod security standards, or configuring network policies and secret volume mounts. Don't use for Workload Identity (use gke-workload-identity), cluster-wide control plane security, RBAC hardening, Binary Authorization, Shielded Nodes, or enabling platform-level GKE add-ons (use gke-platform-security instead).

★ 126
gke-labs
gke-labs/kube-agents

gke-workload-scaling

Manages scaling for GKE workloads using HPA and VPA. Use when configuring Horizontal Pod Autoscaler (HPA), configuring Vertical Pod Autoscaler (VPA), or applying best practices for GKE workload autoscaling. Do not use for cluster-level autoscaling (Cluster Autoscaler), static cluster sizing, or configuring node-level machine styles directly.

★ 126
gke-labs
gke-labs/kube-agents

gke-workload-identity

Configures and diagnoses Workload Identity Federation for GKE authentication failures for Pods (403 "iam.serviceAccounts.getAccessToken" / permission denied, "could not find default credentials", or GKE metadata server unreachable) by verifying cluster and node-pool Workload Identity configuration, the Kubernetes ServiceAccount (KSA) to IAM binding (direct principal binding and legacy Google ServiceAccount impersonation), target-resource IAM roles, and gke-metadata-server health. Use when setting up KSA/GSA bindings (`roles/iam.workloadIdentityUser`, `iam.gke.io/gcp-service-account`) or when a Pod cannot authenticate to Google Cloud APIs. Don't use for in-cluster Kubernetes RBAC errors (API-server authorization), general workload crashes (use gke-workload-troubleshooting), or Pod Security Standards and NetworkPolicies (use gke-workload-security).

★ 126
gke-labs
gke-labs/kube-agents

gke-upgrades

Plans, executes, and validates Google Kubernetes Engine (GKE) cluster upgrades and maintenance operations for both Standard and Autopilot clusters. Produces upgrade plans, pre/post-upgrade checklists, maintenance runbooks with gcloud commands, release channel strategy, and troubleshooting guides. Handles node pool upgrade strategies (surge, blue-green), version compatibility, PDB management, and workload-specific concerns (stateful, GPU, operators). Use this skill whenever the user mentions GKE upgrades, Kubernetes version bumps, node pool maintenance, GKE patching, cluster version management, release channel selection, maintenance windows, surge upgrades, stuck upgrades, or any GKE lifecycle management task — even casual mentions like "we need to upgrade our clusters" or "plan our next GKE maintenance" or "our upgrade is stuck." Don't use for GKE cluster creation, application onboarding, general networking/routing setup, or security policy configurations (use gke-basics or relevant GKE skills instead).

★ 126
gke-labs
gke-labs/kube-agents

gke-tpu-metrics-monitoring

Monitors and troubleshoots GKE TPU workloads, nodes, and node pools using GKE system metrics and PromQL. Use when monitoring TensorCore duty cycle, TPU memory, node readiness, multi-host TPU node pool availability, host maintenance or preemption interruptions, and calculating MTTR or MTBI metrics for GKE TPUs. Don't use for general non-TPU GKE workload monitoring or non-metric TPU debugging.

★ 126