Kustomize
Medium
Troubleshooting
Why can adding a label through commonLabels make kubectl apply fail for an existing Deployment?
Select your answer:
Show answer and explanation
Answer: It also adds the label to selectors, which can't change on a Deployment
Explanation
commonLabels adds its labels to resources, selectors and pod templates. A new label changes spec.selector, which Kubernetes rejects on an existing Deployment. commonLabels is deprecated in favor of the labels field, which leaves selectors alone unless you ask for them.
More medium Kustomize questions
- How do you add a label to every resource without changing any selectors?
- What does an images entry with name: nginx and a digest: sha256:... value do?
- A strategic merge patch lists one container with a new image. What happens to the base's other containers?
- How do you remove a container from a base Deployment with a strategic merge patch?
- When is a JSON 6902 patch a better choice than a strategic merge patch?
- A patch target sets kind: Deployment and labelSelector: tier=backend. Which resources does the patch change?