Prompts for Kubernetes and CI/CD: Deploy, Scale, and Fight 3 AM Incidents via AI Dialogue

Prompts for Kubernetes and CI/CD: Deploy, Scale, and Fight 3 AM Incidents via AI Dialogue

It is 3:14 AM. PagerDuty fires. A pod is stuck in CrashLoopBackOff, the last deploy rolled out 40 minutes ago, and your on-call brain is running at 30 percent capacity. You open a chat window, paste a stack trace, and ask an AI assistant to help you reason through it. Ten minutes later the incident is mitigated. That is not science fiction — that is what well-crafted prompts for Kubernetes actually deliver when platform teams stop treating AI like a toy and start treating it like a junior engineer with infinite patience and zero ego.

The problem is that most DevOps engineers type vague requests like "fix my YAML" and get vague answers back. Generic prompts produce generic output: plausible-looking manifests with wrong API versions, Helm charts that ignore your conventions, and Terraform modules that quietly create public S3 buckets. The difference between a useful answer and a production incident is prompt structure — context, constraints, and a clear definition of done.

This article is a practical collection of prompts for DevOps work: generating manifests and Helm charts, debugging CrashLoopBackOff, wiring GitLab CI pipelines, writing Terraform modules, and handling secrets without leaking them into a chat log. Every prompt comes with an example request and an explanation of which task it closes — deploy, autoscaling, secrets, or a 3 AM incident. The focus is time saved and risk reduced in production, not philosophical debates about whether AI will replace you.

Why structured prompts beat "fix my YAML"

An effective prompt for Kubernetes has four parts: the environment, the constraint, the artifact, and the acceptance criteria. The environment tells the model what it is working with (Kubernetes 1.29, EKS, Istio sidecars, GitLab CI 16.x). The constraint sets boundaries (no cluster-admin, read-only root filesystem, cost cap). The artifact is what you want back (a Deployment, a Helm chart, a pipeline stage). The acceptance criteria define what "correct" means (passes kubeconform, no latest tags, resource requests set).

When you skip the constraints, the model optimizes for looking correct rather than being correct. When you skip acceptance criteria, you cannot tell a good answer from a confident hallucination. Treat the prompt as a spec review, and the output quality jumps immediately.

Prompt 1: Generating production-ready Kubernetes manifests

Task it closes: deploy.

Example request:

You are a platform engineer. Generate a Kubernetes Deployment and Service for a Node.js API. Environment: EKS 1.29, namespace payments, image registry internal. Constraints: 3 replicas, no latest tags, read-only root filesystem, non-root user, resource requests and limits set, liveness and readiness probes on /healthz, PodDisruptionBudget with minAvailable 2. Output only YAML, then list every assumption you made.

The last sentence is the important one. Asking the model to enumerate its assumptions turns hidden guesses into reviewable decisions. You will quickly spot things like a missing securityContext or a probe pointing at the wrong port before they reach the cluster.

Prompt 2: Helm charts that follow your conventions

Task it closes: deploy and reuse across environments.

Example request:

Create a Helm chart for a stateless web service. Values must separate image tag, replica count, resource profiles, and ingress host per environment. Use helpers for fullname and labels. Do not hardcode namespaces. Include a values.schema.json. Explain which values a developer is expected to override and which are platform-owned.

The schema file is the underrated part. It turns a Helm chart from a suggestion into a contract, and it fails fast in CI when someone passes a string where an integer was expected.

Prompt 3: Debugging CrashLoopBackOff and OOMKilled

Task it closes: 3 AM incident.

Example request:

Here is kubectl describe output, the last 50 log lines, and the previous container logs for a pod in CrashLoopBackOff. The app is a Java service with a 512Mi limit. Identify the three most likely root causes ranked by probability, give one diagnostic command per cause, and propose the smallest safe fix. Do not suggest raising the memory limit until you have ruled out a leak.

That final instruction matters. Left alone, models love to "fix" OOMKilled by doubling the limit, which buys you two hours and a bigger bill. Forcing a diagnosis-first flow keeps the fix honest.

Prompt 4: Autoscaling that does not thrash

Task it closes: autoscaling.

Example request:

Design an HPA and VPA strategy for a service with spiky traffic (10x bursts, 30-second peaks) on EKS with metrics-server and KEDA available. Explain why you chose CPU, memory, or a custom metric. Include stabilization windows and scaling policies to prevent flapping. Warn me about any interaction between HPA and VPA that could cause instability.

The warning request is deliberate: HPA and VPA fighting over the same resource is a classic self-inflicted outage, and a good prompt surfaces that risk before you apply it.

Prompts for CI/CD pipelines

Task it closes: build and release automation.

Pipeline goal Prompt seed
GitLab CI for a monorepo "Write a .gitlab-ci.yml with rules-based job execution, caching for node_modules, and a manual production gate."
Docker image hygiene "Produce a multi-stage Dockerfile with a distroless runtime, pinned base image digest, and no build tools in the final layer."
Safe rollouts "Add an Argo Rollouts canary strategy with automated analysis and rollback on error-rate threshold breach."
Faster feedback "Split this pipeline into stages and tell me which jobs can run in parallel without breaking artifact dependencies."

For pipelines, always paste your existing config and ask for a diff rather than a rewrite. A diff is reviewable in seconds; a rewrite is a code review you did not budget for.

Prompts for Docker and Terraform

Task it closes: infrastructure and image supply chain.

Example request for Terraform:

Write a Terraform module for an RDS Postgres instance. Inputs: environment, instance class, multi-AZ flag. Enforce encryption at rest, private subnets only, and a deletion protection flag that defaults to true. Output the connection endpoint. Add a comment for every input explaining the blast radius of changing it.

That blast-radius comment is gold during incident review. It documents intent, not just syntax — something most modules never capture.

Handling secrets without leaking them

Never paste real credentials, tokens, or connection strings into a chat. Replace them with placeholders like DB_PASSWORD_REDACTED and tell the model they are placeholders. If you need help with secret management, ask for patterns — External Secrets Operator, Vault integration, sealed secrets — rather than for a working config with your actual values.

A quick checklist before you apply AI output

  • Validate manifests with kubeconform or a dry-run server-side apply.
  • Diff against the current cluster state before merging.
  • Confirm image tags are pinned and digests match.
  • Check that resource requests and limits exist for every container.
  • Verify no secret, token, or internal hostname leaked into the prompt or the output.

Treat AI output as a pull request from a fast, confident, occasionally wrong teammate. Review it accordingly, and you get the speed without the surprises.

Where this pays off

The real value of prompts for Kubernetes and CI/CD is not that AI writes better YAML than you. It is that it removes the blank-page tax at 3 AM, drafts the boring 80 percent of a manifest or pipeline, and forces you to articulate constraints you would otherwise leave implicit. Teams that adopt this workflow report fewer config drift incidents and faster incident mitigation, because the first responder starts from a structured hypothesis instead of a cold terminal.

Start small. Pick one recurring task — a Helm chart, a pipeline stage, a recurring CrashLoopBackOff — and build a prompt template around it. Save it, version it, share it with your team. Over a month you will have a small library of battle-tested prompts for DevOps that turn hours of toil into minutes of review. Grab your most painful recurring task today, write the four-part prompt, and see what comes back.

← All posts

Comments