12 Kubernetes Prompts That Slash Your Ops Toil: A DevOps Survival Guide
If you've ever spent a sleepless night chasing a CrashLoopBackOff or trying to decipher a cryptic Ingress error, you know the pain. Kubernetes is powerful, but it's also notoriously verbose—and debugging it often feels like archaeology. What if you could offload the grunt work to an AI that speaks fluent YAML and knows the API inside out? With the right prompts, you can turn ChatGPT or Claude into a senior SRE who never sleeps. Here are 12 battle-tested prompts that will save you hours every week.
1. The Manifest Mechanic: Generate a Deployment from Scratch
What it does: Creates a production-ready Deployment manifest with proper resource requests, limits, and health checks—no more copy-pasting from memory.
The Prompt:
Act as a Kubernetes expert. Generate a Deployment manifest for [container image] with the following requirements: [number of replicas], [port], [environment variables]. Include resource requests/limits, liveness and readiness probes, and a rolling update strategy with maxSurge and maxUnavailable. Add comments explaining each field.
Example Use: You're deploying an Nginx reverse proxy for a client. Instead of writing YAML from scratch, you prompt with nginx:1.25, 3 replicas, port 80, and env vars for LOG_LEVEL. The AI returns a complete manifest with sensible values (e.g., requests: cpu: 100m, memory: 128Mi), probes hitting /healthz, and a RollingUpdate strategy. You save 15 minutes and avoid common mistakes like forgetting imagePullPolicy.
2. The Helm Chart Wizard: Scaffold a Chart in Minutes
What it does: Generates a Helm chart structure with templates for Deployment, Service, and ConfigMap, including values.yaml placeholders.
The Prompt:
Create a Helm chart for [app name] with templates for Deployment, Service, and ConfigMap. Use values.yaml for image, replicas, ports, and environment variables. Include a NOTES.txt and a _helpers.tpl with standard labels. Ensure the chart follows best practices: liveness/readiness probes, resource limits, and pod anti-affinity.
Example Use: You need to package a microservice for multiple environments. The prompt yields a chart with values.yaml containing replicaCount: 2, image.repository, and env lists. You can then run helm install and override values per environment—cutting down chart authoring from 2 hours to 20 minutes.
3. The Debugger's Oracle: Diagnose Pod Failures
What it does: Helps you analyze pod statuses and logs to pinpoint the root cause of failures.
The Prompt:
I'm debugging a pod in state [CrashLoopBackOff]. The logs show: [paste logs]. The pod's events are: [paste events]. Analyze these and give a step-by-step debugging plan. Focus on common issues like image pull errors, resource limits, or startup command failures. Also suggest `kubectl` commands to verify each hypothesis.
Example Use: Your pod keeps restarting. You paste the logs showing exec user process caused: exec format error. The AI identifies a wrong architecture (e.g., arm64 image on amd64 node) and suggests checking node.kubernetes.io/arch and rebuilding with --platform linux/amd64. It also recommends kubectl describe pod to see events. This turns a 30-minute investigation into a 5-minute fix.
4. The Service Mesh Whisperer: Ingress and Service Debugging
What it does: Helps you troubleshoot Ingress rules, service discovery, and connectivity issues.
The Prompt:
My Ingress isn't routing traffic to my service. The Ingress YAML is: [paste YAML]. The service YAML is: [paste YAML]. The backend pods are running. What could be wrong? List potential causes (e.g., wrong selector, missing ports, TLS misconfiguration) and provide `kubectl` commands to diagnose each.
Example Use: You have an Ingress for api.example.com that returns 404. The AI spots that your service selector doesn't match the pod labels (e.g., app: myapp vs app: my-app). It suggests checking kubectl get endpoints and verifying the service's targetPort. You fix the selector and traffic flows—saving an hour of head-scratching.
5. The Resource Planner: Rightsize Your Requests and Limits
What it does: Analyzes your current resource usage and recommends optimal requests/limits to avoid waste or throttling.
The Prompt:
Based on the following `kubectl top` output for pods in namespace [namespace]: [paste output]. Suggest optimal CPU and memory requests/limits for each deployment. Consider burstable workloads and set requests to the 99th percentile usage and limits to 2x that. Also suggest VPA recommendations if applicable. Explain the reasoning.
Example Use: You run kubectl top pods and see your API server uses an average of 100m CPU but spikes to 500m. The AI recommends setting requests: 250m and limits: 1 to balance cost and performance. This prevents OOM kills and reduces cluster costs by 30%—a win you can measure.
6. The Security Sentinel: Harden Your Cluster
What it does: Generates a security checklist and suggests concrete improvements for RBAC, Pod Security, and network policies.
The Prompt:
Act as a Kubernetes security auditor. Review the following manifests: [paste YAML]. Identify security issues such as running as root, missing resource limits, or overly permissive RBAC. Provide a prioritized list of fixes with example YAML for each (e.g., securityContext, NetworkPolicy). Follow CIS Kubernetes Benchmark recommendations.
Example Use: You have a deployment running as root with privileged: true. The AI flags it and provides a securityContext with runAsNonRoot: true and capabilities: drop: ["ALL"]. It also suggests a NetworkPolicy to restrict ingress. This turns a security review into a copy-paste exercise.
7. The Log Analyst: Extract Insights from Chaos
What it does: Parses large log dumps to identify errors, patterns, and anomalies.
The Prompt:
I have the following logs from [pod/deployment]: [paste logs]. Identify any errors, warnings, or suspicious patterns. Group them by type and frequency. For each issue, suggest a possible cause and a fix. If you see a stack trace, trace the root cause.
Example Use: Your logs are flooded with connection refused errors. The AI groups them by source IP and notes they all target port 5432, suggesting a database service is down. It recommends checking the PostgreSQL pod status and service endpoints. You restart the DB and the errors vanish—saving you from grepping through thousands of lines manually.
8. The Network Ninja: Craft NetworkPolicies
What it does: Generates Kubernetes NetworkPolicy YAML to enforce pod-to-pod communication rules.
The Prompt:
Create a NetworkPolicy that allows ingress to [app] only from [source app] on port [port]. Also create an egress policy that allows [app] to reach [external IP] on port [port]. Use namespace selectors and pod selectors. Provide the YAML and explain how it works.
Example Use: You need to lock down a database so only the API can reach it. The AI produces a NetworkPolicy with podSelector: {app: api} and ports: 5432. This is a common security requirement that would take time to write correctly—now it's instant.
9. The Autoscaler Architect: Configure HPA and VPA
What it does: Generates Horizontal Pod Autoscaler (HPA) and Vertical Pod Autoscaler (VPA) configurations based on your workload patterns.
The Prompt:
I have a deployment [name] with current CPU average of [value] and memory of [value]. I want to scale based on CPU and custom metrics. Generate an HPA manifest with min/max replicas and target utilization. Also, suggest a VPA mode (auto, initial, off) and manifest if appropriate. Include API version `autoscaling/v2`.
Example Use: Your web app sees spikes during business hours. The AI creates an HPA with minReplicas: 2, maxReplicas: 10 and targetCPUUtilizationPercentage: 70. It also recommends a VPA for the control plane components. You apply both and your app scales automatically—no more nighttime pages.
10. The Upgrade Strategist: Plan a Cluster Migration
What it does: Helps you plan a Kubernetes version upgrade or migration to a new cluster by identifying risks and steps.
The Prompt:
I'm upgrading my cluster from Kubernetes v[old] to v[new]. List the breaking changes and deprecated APIs that might affect my workloads. Provide a migration checklist for the following resources: [list resources]. Include commands like `kubectl convert` and `kubeadm upgrade plan`.
Example Use: You're moving from 1.24 to 1.28. The AI reminds you that apiVersion: networking.k8s.io/v1beta1 Ingress is no longer served and suggests updating to v1. It also flags PodSecurityPolicy removal and points you to Pod Security Standards. This prevents an outage on upgrade day.
11. The Cost Cutter: Optimize Cloud Spend
What it does: Analyzes your cluster configuration and suggests ways to reduce cloud costs, such as node consolidation and spot instances.
The Prompt:
Given this cluster info: [node list with instance types, pod resource usage]. Suggest ways to reduce cloud costs. Consider right-sizing instances, using spot instances for stateless workloads, and enabling cluster autoscaling. Provide a concrete plan with estimated savings (in percentages, not absolute numbers).
Example Use: You have 5 nodes with low utilization. The AI suggests using a smaller instance type and enabling cluster autoscaler to scale down during off-peak. It also recommends taints/tolerations for spot nodes. You implement the plan and see your bill drop by 40%.
12. The Documentation Scribe: Auto-Generate Runbooks
What it does: Creates documentation for your Kubernetes setup, including troubleshooting guides and architecture diagrams (in Mermaid).
The Prompt:
Create a runbook for the [app] deployment in my cluster. Include: 1) Overview of components (Deployment, Service, Ingress, ConfigMap). 2) Common troubleshooting steps (e.g., pod crash, DNS failure). 3) Rollback procedure. 4) A Mermaid diagram of the architecture. Use clear, concise language.
Example Use: You need to hand over your cluster to a new team member. The AI generates a runbook with a Mermaid flowchart showing how traffic flows from Ingress to Service to Pods. It also lists commands like kubectl logs and kubectl rollout undo. This turns a dreaded documentation task into a 10-minute job.
The Bottom Line
Kubernetes doesn't have to eat your life. By crafting specific prompts that mimic the thought process of an experienced SRE, you can delegate the tedious parts—scaffolding, debugging, optimizing—to an AI that never gets tired. The key is to be precise: include exact errors, YAML snippets, and your desired outcome. The more context you give, the better the responses.
Ready to reclaim your evenings? Start with the Debugger's Oracle (prompt #3) next time you see a red pod. Your future self will thank you. And remember: these prompts are just a starting point—adapt them to your own stack and let the AI become your junior SRE, always on call, always fast.
Comments