Skip to content

commandDevOps and cloudkubernetes

Write Kubernetes Manifest

Writes Deployment, Service and config manifests for a service with probes, resource limits and a rollout that can be undone.

npx workspacetemplates add write-k8s-manifest --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/write-k8s-manifest.md15 lines · 1.2 KBFile
---
description: Writes Deployment, Service and config manifests for a service with probes, resource limits and a rollout that can be undone.
argument-hint: "[service name, namespace]"
---

Write Kubernetes manifests for: $ARGUMENTS (service name; infer it from the repository if empty).

1. Look for existing manifests, Helm charts or kustomize folders and match their layout, labels and naming. Read the app for its port, health route, config variables and startup time.
2. Create a Deployment with the image set to a specific tag (never latest), app.kubernetes.io labels, and a RollingUpdate strategy with maxUnavailable 0 and maxSurge 1.
3. Add readinessProbe, livenessProbe and a startupProbe if boot is slow. Point them at the health route, not at /.
4. Set resource requests and limits with a short note on how you chose the numbers. Add securityContext: runAsNonRoot, readOnlyRootFilesystem where the app allows it.
5. Add a Service, a ConfigMap for non-secret settings, and reference secrets by name only. Never write secret values.
6. Run `kubectl apply --dry-run=client -f <dir>` and, if a cluster is reachable, `--dry-run=server`.

Show the files and the dry-run result. Ask before writing them, and never run `kubectl apply` for real.

What it does

A manifest that applies cleanly can still take a service down: no readiness probe, no limits, and a rollout that kills every pod at once. This command writes the set of files with those decisions made on purpose.

It reads the code for ports and health routes, follows the folder layout your repository already uses and validates the YAML with a dry run before it asks to save anything.

Example

you › /write-k8s-manifest billing-api in namespace payments

agent › Proposed k8s/billing-api/: deployment.yaml (3 replicas, probes on /healthz, 250m/256Mi requests), service.yaml, configmap.yaml. Client dry run passed for all three. Secret "billing-db" is referenced, not created. Write these files?

Questions

Does it deploy to my cluster?
No. It only dry-runs the manifests. Applying them stays your decision.
Can it work with Helm?
It follows an existing chart or kustomize layout if it finds one, and writes plain YAML otherwise.
  • Debug Container

    Commanddocker

    Free
  • Deploy Checklist

    CommandDevOps and cloud

    Free
  • Dockerize

    Commanddocker

    Free
  • Document Env Vars

    CommandDevOps and cloud

    Free