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 →
- Add
shop.labelsandshop.selectorLabelshelpers; applylabelsto all metadata. - Keep the existing selectors exactly as they are for now (copy them into
selectorLabels). - 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. - Use
helm diffto 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.
More on Chart Design & Authoring
Your team has 15 near-identical YAML folders, one per microservice per environment. How do you introduce Helm?BeginnerShould you build one generic chart for all microservices or one chart per service?IntermediateA developer hardcoded `namespace: production` in every template. What is wrong and how do you fix it?BeginnerChanging a ConfigMap value in the chart does not restart the pods, so the app keeps old config. What do you change?IntermediateYou need the same chart to support both Ingress and Gateway API HTTPRoute. How do you design it?IntermediateYour chart's Deployment template has grown to 300 lines of nested `if`s. How do you clean it up?Intermediate