Interview Prep/Helm/Chart Design & Authoring

You inherit a chart with no labels helper; every template has different labels. How do you fix it without downtime?

AdvancedScenarioChart Design & Authoring
Answer

Situation read → Adding labels is safe, but changing selectors on Deployments is not (immutable).

What I'd do →

  1. Add shop.labels and shop.selectorLabels helpers; apply labels to all metadata.
  2. Keep the existing selectors exactly as they are for now (copy them into selectorLabels).
  3. If selectors must change, do it in a major chart version with a documented migration: delete the Deployment with kubectl delete deploy shop-api --cascade=orphan, upgrade (new Deployment adopts nothing because labels differ, so it creates new pods), then delete orphaned old ReplicaSets after the new pods are Ready.
  4. Use helm diff to confirm only metadata labels change in step 1.

Why → Metadata labels are mutable; selectors are not.

Interview tip → Saying "selectors are immutable, so I orphan-delete" shows real experience.

All Helm questions Roadmap: Helm

More on Chart Design & Authoring