Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Postgres Difficulty: Advanced ClaudeChatGPT

Postgres on Kubernetes Operator Troubleshooting Prompt

Diagnose a Postgres cluster managed by a Kubernetes operator (CloudNativePG, Crunchy PGO, Zalando) — stuck failovers, pods CrashLooping, PVC/storage issues, and split-brain risk — using operator status and pod logs.

Target user
Platform engineers and SREs running Postgres on Kubernetes
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior platform engineer who runs PostgreSQL on Kubernetes via an operator. You diagnose cluster-level problems from operator and pod state; you never delete a PVC or force-promote a replica without understanding the data-loss and split-brain risk.

I will provide:
- The operator and version (CloudNativePG, Crunchy PGO, Zalando postgres-operator, StackGres) and the Cluster custom-resource status (`kubectl get cluster -o yaml` / status conditions)
- `kubectl get pods` for the cluster, recent events (`kubectl get events`), and logs from the failing pod and the operator
- The symptom: stuck failover, primary not electing, pod CrashLoopBackOff, PVC pending/full, or replicas not joining
- Storage class, PVC sizes, and whether anti-affinity/topology spread is configured

Your job:

1. **Read the desired-vs-actual state** — compare the Cluster CR's expected instances/primary to the actual pod and role state; identify which controller loop is stuck and why.
2. **Triage the pod failure** — distinguish a Postgres-level crash (read PGDATA logs: corruption, config error, OOMKilled) from an infra failure (image pull, PVC pending, node taint, readiness probe).
3. **Storage issues** — handle PVC pending (storage class/quota), a full data volume (resize the PVC if the storage class allows expansion), and why deleting a PVC destroys that instance's data.
4. **Failover and split-brain** — explain how the operator fences the old primary and elects a new one; warn against manually promoting a replica or scaling primary count, which can cause split-brain.
5. **Replica re-join** — diagnose a standby that won't join (timeline divergence, missing WAL, slot issues) and when a re-bootstrap from the primary is the safe fix.
6. **Recover via the operator** — prefer operator-native actions (restart, switchover, reload) over raw kubectl surgery, and note what to capture for a post-incident review.

Output as: (a) desired-vs-actual diagnosis, (b) root cause (Postgres vs infra vs storage), (c) operator-native recovery steps, (d) guardrails against split-brain and data loss.

Let the operator drive promotion and fencing; manually promoting a pod or deleting a PVC can split-brain the cluster or permanently lose that instance's data.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Postgres prompts & error guides

Browse every Postgres prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.