Parameterize Hardcoded Manifests Into a Helm Chart Prompt
Refactor a pile of static Kubernetes YAML into a clean, reusable Helm chart with a well-designed values.yaml, helpers, and sensible defaults, without over-templating.
- Target user
- Platform engineers and chart authors
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Helm chart author turning hardcoded Kubernetes manifests into a maintainable chart. Parameterize what genuinely varies and leave the rest as sane defaults; resist templating everything.
I will provide:
- The raw manifests (Deployment, Service, ConfigMap, Ingress, etc.)
- Which fields differ across environments (image tag, replicas, resources, hostnames, env, secrets)
- The target environments (dev/staging/prod) and any naming convention
Your job:
1. **Decide what becomes a value** — extract fields that vary per environment or per install into values.yaml; keep stable structural fields hardcoded so the templates stay readable.
2. **Design values.yaml** — group logically (image, resources, service, ingress, env), give safe defaults, and structure it so a per-env override file is small and obvious.
3. **Add helpers** — write `_helpers.tpl` for name/fullname/labels (chart, release, managed-by) and apply consistent selector vs metadata labels so upgrades don't break immutable selectors.
4. **Template carefully** — use `{{- with }}` and `{{ toYaml | nindent }}` for optional blocks (resources, nodeSelector, tolerations), `default`, and `required` for must-set values so a missing value fails loudly, not silently.
5. **Wire config and secrets** — checksum-annotate Deployments on ConfigMap/Secret changes to trigger rollouts; don't bake secrets into the chart.
6. **Add guardrails** — a values.schema.json sketch and notes on what NOTES.txt should print.
Output: (a) the values.yaml with defaults and comments, (b) one templated manifest (Deployment) showing the patterns, (c) the _helpers.tpl, (d) a prod overrides snippet, (e) what to verify with `helm template`/`helm lint`.
Related prompts
-
Helm Chart Generator & Refactor Prompt
Generate a production-grade Helm chart from scratch or refactor a messy one — sane values schema, templating helpers, sub-charts, hooks, and upgrade safety — without hardcoding environment-specific cruft.
-
Helm Named Template & _helpers.tpl Refactor Prompt
Refactor a sprawling Helm chart into reusable named templates in _helpers.tpl, eliminating duplicated label blocks, name truncation, and copy-pasted selectors across manifests.