Inferensys

Prompt

Kubernetes Pod CrashLoop Analysis Prompt

A practical prompt playbook for using the Kubernetes Pod CrashLoop Analysis Prompt in production AI workflows to diagnose CrashLoopBackOff states and propose specific remediations.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal user, required inputs, and operational boundaries for the Kubernetes Pod CrashLoop Analysis Prompt.

This prompt is designed for platform engineers and SREs who need to move from raw diagnostic data to a structured root cause analysis when a pod is stuck in a CrashLoopBackOff state. The job-to-be-done is systematic differential diagnosis: you have already gathered the evidence—kubectl describe pod output, container logs, exit codes, resource configurations, and liveness probe definitions—and you need to synthesize that evidence into a ranked list of probable causes with specific, copy-pasteable remediation commands. The ideal user understands Kubernetes primitives and can validate the model's reasoning against their own cluster state, but wants to accelerate the correlation step that connects symptoms to root causes.

You should use this prompt when you have a complete diagnostic snapshot and need a structured analysis artifact for a post-incident review, a runbook entry, or a handoff to another engineer. The prompt expects placeholders for [POD_DESCRIBE_OUTPUT], [CONTAINER_LOGS], [EXIT_CODE], [RESOURCE_LIMITS], [LIVENESS_PROBE_CONFIG], and [NAMESPACE_CONTEXT]. Do not use this prompt for live incident response where a human must make time-critical decisions without review; the output requires validation before any remediation commands are executed. The prompt is also not a substitute for real-time monitoring or alerting—it is a post-hoc analysis tool, not a detection system.

Before executing any remediation commands produced by this prompt, validate them against your cluster's current state, RBAC permissions, and change management policies. The prompt's output is a hypothesis, not a guarantee. Common failure modes include misattributing an OOMKill to a memory leak when the real cause is a misconfigured limit, or recommending a liveness probe delay increase that masks a deeper initialization race condition. Always correlate the model's findings with your own timeline of events and consider running the analysis in a read-only context before applying fixes. For high-severity production incidents, the output should be reviewed by a second engineer before any action is taken.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide whether the Kubernetes Pod CrashLoop Analysis Prompt fits your current incident before you invest time in running it.

01

Good Fit

Use when: You have a pod in CrashLoopBackOff and can provide kubectl describe pod output, container logs, and exit codes. The prompt excels at correlating probe failures, resource limits, and application errors into a structured root cause hypothesis with specific remediation commands.

02

Bad Fit

Avoid when: The failure is purely network-policy or service-mesh related with no pod-level events. Avoid when: You need real-time cluster state rather than a snapshot analysis. Avoid when: The root cause spans multiple services and requires distributed tracing correlation beyond a single pod's lifecycle.

03

Required Inputs

Minimum: Pod name, namespace, and kubectl describe pod output. Strongly recommended: Container logs from the previous crashed instance (--previous), exit codes, and resource limit configuration. Optional but helpful: Liveness/readiness probe definitions and recent deployment events.

04

Operational Risk

Risk: The prompt may propose remediation commands (e.g., kubectl delete pod, config changes) that require human approval before execution. Guardrail: Treat all suggested remediation as a draft. Require an SRE or platform engineer to review and approve any state-changing action before applying it to production clusters.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt with square-bracket placeholders for diagnosing Kubernetes CrashLoopBackOff states from pod events, container logs, and configuration.

This prompt template is designed to be pasted directly into your AI harness or orchestration layer. It accepts structured diagnostic data collected from a Kubernetes cluster and returns a root cause analysis with specific remediation commands. Replace each square-bracket placeholder with real data before execution. The prompt enforces a strict output schema so that downstream tooling—such as ticketing systems, runbook automation, or incident postmortems—can consume the result without manual reformatting.

text
You are a senior platform engineer diagnosing a Kubernetes pod stuck in CrashLoopBackOff.

Analyze the following diagnostic data and return a structured root cause analysis.

[POD_MANIFEST]

[POD_EVENTS]

[PREVIOUS_CONTAINER_LOGS]

[CURRENT_CONTAINER_LOGS]

[NODE_RESOURCE_UTILIZATION]

[LIVENESS_PROBE_CONFIG]

[READINESS_PROBE_CONFIG]

[EXIT_CODES]

[RESTART_COUNT]

[CLUSTER_EVENTS]

[OUTPUT_SCHEMA]
Return a JSON object with these exact fields:
- "primary_root_cause": string (the single most likely cause)
- "confidence": "high" | "medium" | "low"
- "evidence": array of strings (specific log lines, event messages, or config values that support the root cause)
- "alternative_hypotheses": array of { "cause": string, "likelihood": "high" | "medium" | "low", "evidence_for": array of strings, "evidence_against": array of strings }
- "remediation_steps": array of { "action": string (a specific kubectl command, manifest change, or operational action), "expected_effect": string, "risk": "low" | "medium" | "high", "reversible": boolean }
- "missing_data": array of strings (diagnostic information that would increase confidence if collected)
- "prevention_recommendations": array of strings (long-term fixes to prevent recurrence)

[CONSTRAINTS]
- Do not speculate beyond the provided data. If evidence is insufficient, set confidence to "low" and list what is missing.
- Prefer exit codes and log messages over generic patterns.
- If the liveness probe configuration is the likely cause, explain the exact threshold mismatch.
- If resource limits are implicated, cite the specific limit and the observed utilization.
- Do not recommend deleting the pod as the only remediation step.
- If multiple causes are possible, rank alternative hypotheses by likelihood.

After pasting this template into your harness, replace each placeholder with real data collected from kubectl describe pod, kubectl logs, and your monitoring system. The [OUTPUT_SCHEMA] block is part of the prompt itself—it tells the model exactly what shape to return. Do not remove it. If your application layer already enforces a JSON schema via function calling or structured output mode, you can replace the inline schema with a reference to your tool definition. Always validate the returned JSON against the expected fields before surfacing remediation steps to an operator or executing them automatically. For production incident response, route any remediation step marked "risk": "high" or "reversible": false through a human approval queue before execution.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Kubernetes Pod CrashLoop analysis prompt. Each placeholder must be populated from cluster state, monitoring systems, or runbooks before the prompt is submitted. Missing or stale data is a leading cause of incorrect root cause hypotheses.

PlaceholderPurposeExampleValidation Notes

[POD_NAME]

Identifies the specific pod in CrashLoopBackOff state

payment-processor-7d4f8b9c-abcde

Must match a running or recently terminated pod in the target namespace. Validate with kubectl get pods before use.

[NAMESPACE]

Scopes the analysis to the correct Kubernetes namespace

production

Must be an existing namespace. Null not allowed. Validate with kubectl get ns.

[CONTAINER_LOGS]

Provides the last N lines of container logs from the crashing container

Error: Cannot connect to database at 10.0.1.50:5432

Must include stderr and stdout. Validate that logs are from the correct container and not truncated. Minimum 50 lines recommended.

[PREVIOUS_CONTAINER_LOGS]

Captures logs from the previous crashed instance if available

Killed: Out of memory (OOM)

Null allowed if no previous instance exists. Use kubectl logs --previous. Validate timestamp range overlaps with last crash event.

[EXIT_CODE]

The integer exit code from the terminated container

137

Must be an integer. 137 indicates OOMKilled. Cross-reference with pod events for signal confirmation. Null not allowed.

[POD_EVENTS]

Kubernetes event stream for the pod showing lifecycle transitions

Back-off restarting failed container

Must include event type, reason, message, and timestamp. Validate events are sorted chronologically. Minimum 10 events or full pod lifetime.

[RESOURCE_LIMITS]

The CPU and memory limits and requests configured for the container

limits: memory: 256Mi, cpu: 500m

Must be extracted from pod spec. Validate against actual node allocatable resources. Null allowed if no limits are set, but flag as risk factor.

[LIVENESS_PROBE_CONFIG]

The liveness probe configuration including path, port, initialDelaySeconds, and failureThreshold

httpGet: path: /healthz, port: 8080, initialDelaySeconds: 30

Null allowed if no probe is configured. If present, validate that the probe endpoint is reachable from within the cluster. Cross-reference probe timing with crash timing.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Kubernetes Pod CrashLoop Analysis Prompt into an SRE or platform engineering workflow with validation, retries, and safe execution.

This prompt is designed to be called programmatically during an incident or as part of a post-incident review pipeline. The primary integration point is a backend service or an SRE bot that receives a pod identifier (namespace/name) and a time window, then fetches the required Kubernetes objects before assembling the prompt. The implementation harness must handle data gathering, prompt assembly, model invocation, output validation, and safe presentation of remediation commands. Because the output includes specific kubectl commands and configuration patches, the system should never auto-execute these commands without human review. The harness should treat the model output as a structured analysis artifact that informs a human operator's decision, not as an automated remediation script.

To wire this into an application, build a data-gathering function that runs kubectl or the equivalent Kubernetes API calls to collect: kubectl describe pod [POD_NAME] -n [NAMESPACE], kubectl logs [POD_NAME] -n [NAMESPACE] --previous --tail=200, kubectl get events -n [NAMESPACE] --field-selector involvedObject.name=[POD_NAME], and the pod's full YAML manifest. If the pod is managed by a Deployment, StatefulSet, or DaemonSet, also fetch the owning controller's manifest to capture liveness/readiness probe configurations, resource limits, and volume mounts. Package these into the [POD_DESCRIBE_OUTPUT], [PREVIOUS_CONTAINER_LOGS], [POD_EVENTS], and [POD_MANIFEST_YAML] placeholders. Set [TIME_WINDOW_MINUTES] based on the incident timeline. The harness should validate that all required inputs are non-empty before sending the prompt; if logs are missing because the container never started, populate the field with a note like `

No previous container logs available — container may be failing before log output begins."` This prevents the model from hallucinating log content."

For model choice, use a model with strong structured output capabilities and a context window large enough to hold the full manifest and log output. GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable. Set temperature to 0.1–0.2 to reduce variance in root cause classification. Request a JSON output schema matching the [OUTPUT_SCHEMA] defined in the prompt template, and implement a post-generation validation step that checks: (1) the root_cause_hypotheses array is non-empty, (2) each hypothesis has a non-empty evidence array with specific log lines or event timestamps, (3) remediation_steps contain actionable commands or configuration changes, and (4) the confidence_score is a float between 0.0 and 1.0. If validation fails, retry once with the validation errors appended to the prompt as [PREVIOUS_VALIDATION_ERRORS]. If the retry also fails, surface the raw output to a human reviewer with a clear flag that automated validation did not pass.

Log every invocation with the pod identifier, model version, prompt version, token usage, and validation result. This audit trail is critical for post-incident review and for debugging cases where the model misdiagnosed a CrashLoop. Store the structured output in the incident timeline or a dedicated analysis log so that SRE teams can correlate the AI-generated hypotheses with the actual root cause discovered during resolution. Over time, this log becomes a dataset for evaluating prompt accuracy and for fine-tuning if the team moves to a custom model. Avoid logging raw pod manifests that may contain secrets; redact env values and secretRef entries before persisting logs.

The highest-risk failure mode is the model generating plausible but incorrect remediation commands. A hallucinated kubectl patch or an incorrect resource limit adjustment can worsen an outage. The harness must render remediation commands in a read-only format with a clear warning that they require human review before execution. If integrating with a runbook automation system, add an explicit approval gate that requires an SRE to confirm each command. For configuration changes like liveness probe tuning or resource limit adjustments, the harness should generate a diff view against the current manifest and require a pull-request-style review before applying. Never wire this prompt directly to a kubectl apply call without human-in-the-loop approval.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the structured JSON output produced by the Kubernetes Pod CrashLoop Analysis Prompt. Use this contract to parse, validate, and integrate the model's response into downstream systems.

Field or ElementType or FormatRequiredValidation Rule

root_cause_hypothesis

string

Must be a non-empty string. Check length > 20 characters. Must not be a generic statement like 'pod is crashing'.

confidence_score

float

Must be a number between 0.0 and 1.0. Parse check: valid float. Range check: 0.0 <= x <= 1.0.

evidence_log_snippets

array of strings

Must be a non-empty array. Each element must be a non-empty string. Validate array length > 0.

evidence_event_reasons

array of strings

Must be a non-empty array. Each element must match a known Kubernetes event reason pattern (e.g., 'BackOff', 'Unhealthy', 'OOMKilled').

contributing_factors

array of objects

Each object must have 'factor' (string, non-empty) and 'evidence' (string, non-empty) keys. No extra keys allowed.

remediation_steps

array of objects

Each object must have 'action' (string, non-empty) and 'command' (string, non-empty) keys. 'command' must start with a valid executable or kubectl verb.

requires_human_approval

boolean

Must be a strict boolean (true or false). No string equivalents allowed.

analysis_id

string

If present, must match the regex pattern ^[a-f0-9-]{36}$ for UUID v4 format. Null allowed.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when using an LLM for Kubernetes CrashLoop analysis and how to guard against it.

01

Hallucinated Kubernetes API Fields

What to watch: The model invents resource limits, probe configurations, or volume mounts that don't exist in the actual pod spec. This happens when the prompt lacks the full manifest or the model defaults to common patterns. Guardrail: Always provide the full kubectl get pod -o yaml output as [CONTEXT]. Validate any suggested field change against the original manifest before applying it.

02

Misattribution of Exit Codes

What to watch: The model incorrectly maps exit code 137 to an application panic instead of an OOMKill, or misinterprets exit code 1 as a generic failure without checking container logs. Guardrail: Include a lookup table of standard Kubernetes exit codes and signals in the system prompt. Require the model to cite the specific log line that supports its exit code interpretation.

03

Ignoring Probe Timing Mismatches

What to watch: The model blames application startup time without calculating whether initialDelaySeconds is shorter than the measured startup duration from logs. Guardrail: Add an explicit instruction to compare initialDelaySeconds against the timestamp of the first successful readiness log entry. Flag any mismatch as a primary hypothesis.

04

Overlooking Node-Level Resource Pressure

What to watch: The model focuses exclusively on pod-level resource limits and misses node-level conditions like MemoryPressure, DiskPressure, or PIDPressure that can cause evictions. Guardrail: Require kubectl describe node output as a mandatory input. Instruct the model to check node conditions before concluding a pod-level resource issue.

05

Confusing CrashLoopBackOff with ImagePullBackOff

What to watch: The model conflates different pod failure states, suggesting image pull fixes for a crash loop or vice versa, especially when pod events are truncated or interleaved. Guardrail: Add a pre-analysis step that classifies the pod status and sorts events chronologically. Instruct the model to state the observed pod status before proposing any root cause.

06

Proposing Destructive Commands Without Confirmation

What to watch: The model suggests kubectl delete pod, scale down, or config changes that could cause data loss or service disruption without warning. Guardrail: Add a hard constraint that any remediation command must include a risk assessment and a rollback command. Flag all destructive suggestions for human approval before execution.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality and safety of the Kubernetes Pod CrashLoop Analysis prompt output before integrating it into an on-call or automated diagnostic workflow.

CriterionPass StandardFailure SignalTest Method

Root Cause Specificity

Output identifies a specific, testable hypothesis (e.g., 'OOMKilled due to memory limit of 128Mi') rather than a generic category (e.g., 'resource issue').

Vague output like 'check your config' or 'resource problem' without a specific limit, path, or probe name.

Parse output for a concrete resource value, file path, exit code, or probe configuration parameter.

Evidence Grounding

Every hypothesis is directly linked to a provided log line, event field, exit code, or probe definition from the [INPUT].

A claim is made with no supporting evidence from the provided context, or evidence is hallucinated.

For each claim, check if a corresponding string or value exists in the [INPUT] data. Flag any unsupported claims.

Remediation Actionability

Remediation steps include specific kubectl commands, exact YAML snippets, or configuration values to change.

Remediation is a generic suggestion like 'increase the memory limit' without specifying the new value or the resource to patch.

Check if the output contains a runnable command (e.g., kubectl set resources...) or a complete YAML patch block.

Exit Code Interpretation

The analysis correctly interprets the container exit code (e.g., 137 for OOMKill, 1 for application error) and ties it to the root cause hypothesis.

The exit code is ignored, misinterpreted, or a standard exit code is treated as an unknown mystery.

Provide a known exit code (e.g., 137) in the test input and verify the output explicitly mentions OOMKill.

Probe Configuration Analysis

If liveness/readiness probes are defined, the analysis evaluates their parameters (e.g., initialDelaySeconds, timeoutSeconds) against the failure event.

Probe configurations are present in the input but the analysis fails to mention them or their potential misconfiguration.

Input a pod spec with a short initialDelaySeconds and a CrashLoop. Verify the output flags this as a potential cause.

Diagnostic Ordering

Hypotheses are ranked by likelihood, with the most probable cause based on the evidence listed first.

A rare edge case is presented as the primary hypothesis before an obvious, evidence-backed cause like OOMKill.

Input a clear OOMKill scenario. Verify that memory exhaustion is the first hypothesis, not a secondary or tertiary one.

Safety and Command Verification

All provided commands are read-only or safe for a human to review. Destructive commands include a clear warning and require explicit approval.

The output suggests a destructive command like kubectl delete pod as the first step without context or a warning.

Scan the output for destructive verbs (delete, scale down). Flag any that lack a preceding warning or conditional statement.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single [POD_NAME] and [NAMESPACE] placeholder. Accept raw kubectl describe pod and kubectl logs --previous output pasted directly. Skip structured output requirements—let the model return free-text analysis. Focus on speed and exploration.

Prompt modification

code
Analyze this CrashLoopBackOff pod:

Pod description:
[POD_DESCRIBE_OUTPUT]

Previous container logs:
[CONTAINER_LOGS]

What is the most likely cause of the crash loop?

Watch for

  • Hallucinated exit codes when logs are truncated
  • Missing distinction between OOMKilled and application-level crashes
  • Overconfident single-cause answers when multiple factors interact
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.