gke-stall-detection
Read-only detection of controllers that stopped making progress without erroring — observedGeneration lag, stuck progress conditions, repeating warning events, and references to objects that do not exist — in one namespace or one kind.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 126
- Forks
- 44
01 前言 Front Matter
- name
- gke-stall-detection
- description
- Read-only detection of controllers that stopped making progress without erroring — observedGeneration lag, stuck progress conditions, repeating warning events, and references to objects that do not exist — in one namespace or one kind.
02 资源文件 1
- 脚本scripts/stall_report.py36.1 KB
03 SKILL.md 正文
GKE Stall Detection
Use this skill when a controller has gone quiet rather than red: a Gateway that never programs, a rollout that never finishes, a custom resource whose status stopped following its spec, an HTTPRoute nobody accepted. The symptom-driven skills (workload-triage-scan, the pod-* skills, gke-reliability) start from a failing pod or a bad event; this one starts from the absence of progress, which those states never show. It is read-only: it lists objects, reads their status and events, resolves referenced names, and proposes nothing beyond naming what is missing.
When to run it
- A user reports something "stuck", "still pending", "never came up", or "not reconciling" and nothing is CrashLooping.
- A Gateway, HTTPRoute, Certificate, Config Connector or Argo-managed object has been in the same state for longer than its controller should need.
- Before declaring a namespace healthy in a reliability review: a silent stall is what that review otherwise misses.
Heuristics and thresholds
scripts/stall_report.py, in this skill's directory (the base directory the harness gives when it loads the skill), applies four heuristics to every object it reads. Each is gated by an age threshold, so a controller that is merely slow is not reported.
| Heuristic | Fires when | Age measured from |
|---|---|---|
generation-lag |
metadata.generation is ahead of status.observedGeneration (objects without observedGeneration are skipped) |
newest managedFields entry that wrote f:spec |
stale-condition |
A Progressing, Accepted, Programmed, ResolvedRefs, Ready or Available condition is not True, including conditions nested under status.listeners[] or status.parents[] |
the condition's lastTransitionTime |
repeating-warnings |
A Warning event on the object has a count of at least 3, spans at least the threshold, and was last seen within the threshold | the event's first to last occurrence |
dangling-reference |
The spec names an object that does not exist: certificateRefs, configMapRef, configMapKeyRef, secretRef, secretKeyRef, parentRefs, backendRefs, and volume configMap/secret/persistentVolumeClaim sources; optional: true references are skipped |
newest managedFields entry that wrote f:spec |
Thresholds live at the top of the script: DEFAULT_STALL_MINUTES = 15 for every kind, and STALL_MINUTES_BY_KIND for kinds whose API names its own horizon — Deployment is 10, matching the default progressDeadlineSeconds. --threshold-minutes replaces both for one run. Pods in Succeeded or Failed phase are skipped by every heuristic, and so are finished objects: a Job whose Complete or Failed condition is True, and anything whose spec asks for zero replicas (a Deployment's retired ReplicaSets, a scaled-down StatefulSet). A Gateway's own Programmed=False row is dropped when its in-cluster proxy Deployment asks for zero replicas: the gateway is switched off on purpose. The proxy is found from the GatewayClass controllerName, in the Gateway's namespace (and in envoy-gateway-system for Envoy Gateway); the check reads the GatewayClass and those Deployments, only when that row is reported, and a read that fails keeps the row. The Gateway's other rows, and every HTTPRoute row, are reported as usual. A Deployment with spec.paused set is not read for stale conditions. References are resolved from kubectl get <kind> -o name, so Secret contents are never read — and a kind the agent's identity cannot list is never reported missing. On the default read-only permission set the Cluster Agent reaches its cluster as a GSA that cannot list Secrets, so Secret-typed references (certificateRefs, secretRef, secretKeyRef, volume secret) go unchecked there; the signal is a warning: cannot list secrets line on stderr, and the object's own conditions and warning events still carry the case. An identity that can list Secrets (a custom permission set, or the script run from an operator's workstation) gets the dangling-reference row too.
A single run reads one snapshot, so repeating-warnings cannot watch a count move; the span and recency conditions are its stand-in. Run the script twice a few minutes apart when a rising count is the evidence you need.
Running it
Run these from this skill's directory (the base directory the harness gives when it loads the skill), where scripts/stall_report.py is.
# Every namespaced kind in one namespace (kubectl api-resources decides which):
python3 scripts/stall_report.py --namespace <namespace>
# One or more kinds, as kubectl names them:
python3 scripts/stall_report.py --namespace <namespace> --kind gateways.gateway.networking.k8s.io,httproutes.gateway.networking.k8s.io
# A different horizon, or machine-readable output:
python3 scripts/stall_report.py --namespace <namespace> --threshold-minutes 60 --json
The table has one row per object and heuristic — OBJECT, HEURISTIC, DETAIL, STALLED_FOR — and always ends with stalled resources: <count>, the number of distinct objects with at least one row. A healthy namespace prints the header and stalled resources: 0. The scan reads one kind per kubectl get, so a kind whose listing is too large for the shell's output cap or that the identity cannot list is left out on its own: a warning: line on stderr names it and says its objects are missing from the count. A warning: line also names a referent kind the identity cannot list; references to it are then never reported missing. Only a scan that could read no kind at all exits non-zero.
Worked example: a Gateway waiting for a Secret that will never exist
A Gateway whose HTTPS listener names a TLS Secret that certificate automation was never going to create stays Accepted=True forever. The GKE Gateway controller sets Programmed=False Invalid on the Gateway and ResolvedRefs=False InvalidCertificateRef on the listener, emits a Warning SYNC event naming the Secret every few minutes, and never assigns an address; the HTTPRoutes behind it are accepted and never programmed, and nothing goes red. (Rows abridged: the Ready=False NotReady conditions on the Gateway and the listener, and the listener's own Programmed=False, appear too.)
$ python3 scripts/stall_report.py --namespace edge --kind gateways.gateway.networking.k8s.io
OBJECT HEURISTIC DETAIL STALLED_FOR
Gateway/edge dangling-reference listeners[0].tls.certificateRefs -> Secret/edge-tls not found 6h12m
Gateway/edge stale-condition Programmed=False Invalid 6h11m
Gateway/edge stale-condition listeners[https] ResolvedRefs=False InvalidCertificateRef 6h11m
Gateway/edge repeating-warnings SYNC x743: failed to translate Gateway "edge/edge": Error GWCER102: Secret edge/edge-tls not found. 6h10m
stalled resources: 1
The report names the object, the missing Secret and the stall duration from warning events alone. The first row is the one the identity decides: under the default read-only permission set it is absent, stderr carries warning: cannot list secrets in edge; references to secrets are not checked, and the listener's ResolvedRefs condition and the repeating SYNC events are what name the Secret. The HTTPRoutes behind the listener carry no row of their own — they are accepted, and the stall is the Gateway's — so run against the namespace that holds the Gateway, not only the routes. Confirm the reference with kubectl get gateway edge -n edge -o jsonpath='{.spec.listeners[*].tls.certificateRefs}' and check whether the Secret is expected from automation (a Certificate or ManagedCertificate in the namespace, itself possibly a row in the same report) or was simply never created.
The same four heuristics apply without Gateway-specific code: a Deployment whose pods cannot start because envFrom names a missing ConfigMap shows dangling-reference on the Deployment and stale-condition Ready=False on its Pods; a Config Connector or other custom resource whose controller is wedged shows generation-lag.
Recording the finding
You work under a strict read-only boundary: no patches applied, no Pull Requests opened. Report in your final answer.
- A request that gives a report format wins: format the answer exactly as it says. A stall alert raised through the Session KV server's
controller-stallinject arrives as such a request, with theWhat's wrong/Why/What to dotemplate and, when there is a fix, aTo authorize:line; that shape is what gets the report saved so a reply of "apply" can act on it. Quote the scan'sstalled resources: <count>line inWhy. - Otherwise, follow the shape in
workload-triage-scan/references/reporting.md: which objects are stalled, for how long, on which heuristic, and what each is waiting for (the missing Secret, the unmet condition), grounded in the report rows and the confirming kubectl reads; or the statement that the namespace has no stalled resources. Add YAML creating or correcting the missing reference when one is identifiable.
A report with no rows is a result, not a failure to find something: say the namespace has no stalled resources and what threshold that was measured at.
04 同仓库更多 Skills
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.
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).
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.
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).
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).
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.