Originally published at claudeguide.io/claude-code-kubernetes-devops
Claude Code for Kubernetes and DevOps: YAML Generation and Automation
Claude Code generates production-quality Kubernetes YAML manifests from plain English descriptions — Deployments, Services, ConfigMaps, Secrets, HPA, PodDisruptionBudgets, and Helm charts — and can troubleshoot cluster issues by reading your kubectl output directly. A full microservice deployment that takes 2–3 hours to write manually takes under 15 minutes with Claude Code.
This guide covers the full DevOps workflow: YAML generation, Helm chart authoring, CI/CD pipeline integration, and live cluster troubleshooting.
Setup: Add Kubernetes Context to CLAUDE.md
Before generating any manifests, add your cluster conventions to CLAUDE.md:
## Kubernetes Configuration
- Cluster: GKE (Google Kubernetes Engine) on us-central1
- Namespace convention: {app}-{env} (e.g., payments-prod, payments-staging)
- Resource limits: always set both requests AND limits
- Image registry: gcr.io/my-project/
- Node selector: environment=production for prod workloads
- Labels: app, env, version (all required)
- Liveness/readiness probes: required on all Deployments
- Anti-affinity: prefer spread across availability zones
Claude applies these rules to every generated manifest without being re-told each session.
Generating a Complete Deployment
claude "Generate a Kubernetes Deployment for a Node.js API service:
- Image: gcr.io/my-project/api:v1.2.0
- 3 replicas
- Port 3000
- Env vars: NODE_ENV=production, PORT=3000, DB_URL from a Secret named api-secrets
- CPU request: 250m, limit: 500m
- Memory request: 256Mi, limit: 512Mi
- Liveness probe: GET /health every 30s
- Readiness probe: GET /ready every 10s
Apply CLAUDE.md conventions."
Output (excerpt):
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
namespace: api-prod
labels:
app: api
env: production
version: v1.2.0
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
env: production
version: v1.2.0
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey: topology.kubernetes.io/zone
labelSelector:
matchLabels:
app: api
containers:
- name: api
image: gcr.io/my-project/api:v1.2.0
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: production
- name: DB_URL
valueFrom:
secretKeyRef:
name: api-secrets
key: db-url
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /health
port: 3000
periodSeconds: 30
readinessProbe:
httpGet:
path: /ready
port: 3000
periodSeconds: 10
Mid-Article CTA
Need 300 tested prompts for DevOps, infrastructure, and deployment workflows? Power Prompts 300 ($29) includes Kubernetes manifest generation, Helm chart templates, GitHub Actions CICD pipelines, and CLAUDE.md templates for 5 project types.
Horizontal Pod Autoscaler
bash
claude "Generate an HPA for the api deployment.
- Min: 3 replicas, Max: 20 replicas
- Scale up when CPU
[→ Get Power Prompts 300 — $29](https://shoutfirst.gumroad.com/l/agfda?utm_source=claudeguide&utm_medium=article&utm_campaign=claude-code-kubernetes-devops)
*30-day money-back guarantee. Instant download.*
Top comments (0)