Your YAML Isn't Too Specific for an LLM: How to Prompt Kubernetes and Terraform Reviews That Catch Crashes Before Prod

A CrashLoopBackOff at 2 a.m. almost never starts with a broken image. It starts with a manifest that looked fine in review: a missing liveness probe, a memory limit set to the same value as the request, a restartPolicy nobody questioned. The reviewer was tired, the diff was 400 lines, and YAML is boring to read by hand. That is exactly the work an LLM does well — if you stop asking it to "check my config" and start asking it to hunt specific classes of errors.

The myth worth killing first: "LLMs don't understand infrastructure, YAML is too specific." Wrong model. An LLM is a strong reviewer and generator of IaC as long as you hand it context — Kubernetes version, Terraform provider, target environment — and name the failure class you want found. Below is a set of prompts that do that, each with the situation it is for and what to paste alongside it.

Context first, or every prompt below is noise

Before any prompt, paste three lines at the top: cluster version (e.g. v1.31), target environment (dev/staging/prod), and the provider or runtime (EKS, GKE, bare kubeadm; Terraform provider hashicorp/aws ~> 5.x). Version matters because PodDisruptionBudget moved from policy/v1beta1 to policy/v1 in 1.21 and deprecated fields silently drop on apply. An LLM without the version will happily generate a manifest your API server rejects. More on the topic: “Terraform Prompts That Think Like an SRE: Turning an LLM Into a Module Author, Plan Reader, and Drift Hunter”.

Paste the whole file, not a fragment A probe prompt run on the container stanza alone misses that `terminationGracePeriodSeconds` is shorter than the probe's `failureThreshold × periodSeconds` — a combination that guarantees a killed pod mid-shutdown.

Audit a Deployment manifest vs. write one from scratch

These are different jobs and mixing them produces mush. Audit is where the LLM wins: it reads an existing file and reports what will break. Generation is where it needs guardrails, because it will invent resource values.

Prompt for the audit:

You are reviewing a Kubernetes Deployment for production. Cluster: v1.31, environment: prod.

Check ONLY these classes and list each finding as: severity (blocker/warning), field path, why it fails, exact fix.

1. Resource requests/limits: missing limits, limit == request with no headroom, memory limit lower than typical JVM/heap needs.
2. readiness/liveness/startup probes: missing, identical, too aggressive (failureThreshold*periodSeconds < app boot time), liveness checking a dependency instead of the process.
3. restartPolicy and termination: grace period vs. probe timing, preStop hooks, PodDisruptionBudget absence.
4. Image and security: :latest tag, missing runAsNonRoot, privileged containers.
Deployment:

<paste YAML>

For generation, flip it: give the LLM the app's boot time, memory profile, and expected replica count, and ask for a manifest with those numbers justified. If it returns limits: memory: 128Mi for a Spring Boot service, you asked wrong — tell it the heap.

CrashLoopBackOff: describe plus logs vs. logs alone

Logs alone tell you what the app said before dying. kubectl describe pod tells you why the kubelet killed it — OOMKilled, failed liveness, image pull. The prompt needs both, and it needs the previous container's logs.

A pod is in CrashLoopBackOff. Here are three inputs:

--- kubectl describe pod output (Events section matters most) ---

<paste>
--- kubectl logs --previous ---

<paste>
--- the container's resources block ---

<paste>
Rank the likely causes. For each: the single line of evidence that supports it, and the exact command or manifest change to confirm or fix it. Do not suggest 'increase memory' unless the evidence shows OOMKilled.

That last sentence is the whole trick. Left alone, an LLM defaults to "raise the limits" — the infrastructure equivalent of restarting the router.

Logs alone vs. logs plus describe
Logs only
  • Shows what the app printed
  • Misses OOMKilled and failed probes
  • Leads to 'raise the memory limit'
Logs + describe + resources
  • Events show the kubelet's reason
  • OOMKilled vs liveness failure is visible
  • Fix points at one field

Helm values: generate vs. verify against the chart

Asking an LLM to "write Helm values" with no chart in context produces plausible keys that don't exist. Two working modes:

  • Generate when you paste the chart's values.yaml and the target environment. Prompt: "Given this values.yaml, produce a prod override file changing only replicas, resources, and ingress host. Mark any key you are unsure exists."
  • Verify when you paste your override and the chart's values.yaml. Prompt: "Diff these keys against the chart schema. List keys in my override that the chart does not define, and chart keys I left at defaults that are unsafe for prod."

The verify mode catches the classic: an override sets resources.limits.memory but the chart nests it under a different parent, so the value is silently ignored on helm upgrade.

Terraform plan: destructive changes vs. a clean diff

terraform plan output is where LLMs earn their keep, because a human skims 300 lines of ~ update in-place and misses one -/+ replace. Prompt: More on the topic: “Terraform & IaC: The Myths That Cost You Money and How Infrastructure as Code Actually Works”.

Read this Terraform plan. Environment: prod, provider aws ~> 5.x.

Output a table: resource address

| action (create/update/replace/destroy) | what breaks if applied | is this expected for the stated change?

Then flag every 'replace' and 'destroy' separately. For any replace on a stateful resource (RDS, EBS, S3 bucket), say explicitly what data is at risk.

Plan:

<paste plan output>

For explaining a diff between two plan files — say, before and after a variable change — ask: "Compare plan A and plan B. What new resources appear, what disappears, and what changed only in count or size?" That is a five-second answer an LLM gives correctly if you paste both files.

State drift is a separate question A plan shows what Terraform will do; drift is what already happened outside it. Ask the LLM to compare `terraform state list` output against your repo's resource blocks and name resources that exist in state but not in code — those are the ones a colleague created by hand at 5 p.m. on a Friday.

Secret leaks in manifests vs. in Terraform variables

Both leak, differently. In Kubernetes, secrets hide in env blocks and ConfigMap data that someone pasted a token into. In Terraform, they hide in *.tfvars and in default values of variables. One prompt handles both if you describe the format: More on the topic: “Docker, Kubernetes, and the LLM That Asks "Why?": Prompts That Diagnose a Pod Instead of Blindly Restarting It”.

Scan the following files for anything that looks like a credential: API keys, tokens, passwords, connection strings with embedded auth, private keys.

For each hit: file, line, what it is, and whether it is already committed (assume yes).

Then give the fix: Kubernetes Secret + external secret operator reference, or Terraform variable marked sensitive with no default.

<paste files>

If it finds something real, the fix matters more than the find.

NetworkPolicy and PodDisruptionBudget: the two most-skipped manifests

These get written last, under deadline, and are wrong in predictable ways. For NetworkPolicy, the LLM needs your namespace layout and which services talk to which — paste a short list. Prompt: "Write a default-deny ingress policy plus explicit allows for these flows: frontend→api on 8080, api→postgres on 5432, api→external DNS on 53. Cluster v1.31. Note that DNS egress must be allowed or every pod breaks."

For PDB, the prompt is a math check: "Given 3 replicas and a PDB with minAvailable: 2, how many pods can be evicted during a node drain? What happens if a rolling update needs to take 2 down at once?" The answer — zero evictions possible, update stalls — is the kind of arithmetic an LLM does cleanly and a human misses until the drain hangs.

CI pipeline review vs. manifest review

Different failure modes. A CI prompt should ask about image build caching, secret exposure in logs, and whether the pipeline can deploy a manifest that failed validation. Prompt: "Review this GitHub Actions workflow for an image build and deploy. Flag: secrets echoed to logs, missing terraform validate / kubectl apply --dry-run=server gate before deploy, cache keys that never invalidate, and any step that runs with write access to prod on a PR from a fork."

What to pick, and when

Situation Prompt Why this one
New manifest, pre-merge Deployment audit Finds probe/limit classes a human skims
Pod already down describe + previous logs Evidence-first, no guesswork
Helm override Verify against values.yaml Catches silently ignored keys
Terraform apply Plan reader Surfaces replace/destroy on stateful resources
Compliance sweep Secret scan One pass over k8s and tfvars
Node drain planning PDB math Arithmetic a human gets wrong under pressure

The rule underneath all of them: an LLM is a reviewer with infinite patience and zero context unless you give it some. Name the version, the environment, and the failure class — and it will catch the missing probe before the pager does. Skip the context, and you get a confident paragraph about best practices that helps nobody at 2 a.m.

Start with the audit prompt on your next manifest diff. It takes ninety seconds and it is the cheapest review you will run all week.

Rules and figures are stated as of November 2026.

← All posts

Ask AI about this article

Ask a question about this article — ASI Biont will answer based on its text.