Interview Prep/Helm/Chart Design & Authoring

A developer hardcoded `namespace: production` in every template. What is wrong and how do you fix it?

BeginnerScenarioChart Design & Authoring
Answer

Situation read → The chart can no longer be installed into any other namespace; helm install -n staging would still create objects in production, while the release record lands in staging.

What I'd do →

  1. Remove metadata.namespace from templates, or set it to {{ .Release.Namespace }} for clarity.
  2. Replace hardcoded namespaces in DNS names with {{ .Release.Namespace }} (api.{{ .Release.Namespace }}.svc.cluster.local).
  3. Add a CI check: helm template x ./chart -n ci-test | grep -E '^\s+namespace:' | grep -v ci-test must be empty.

Why → The namespace is a deploy-time decision; charts must stay portable.

Interview tip → Note that release records and objects in different namespaces confuse helm uninstall.

All Helm questions Roadmap: Helm

More on Chart Design & Authoring