[Feature] Set labels conditional spec selector #1064
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
I am facing a use-case where i would like to set common labels to all resources in my Kpt pipeline. To do this, i have tried using set-labels.
One of the common labels I want to set on all resources is app.kubernetes.io/version.
The problem is, set-labels also sets .spec.selector labels on deployments, and this field is immutable. This means, that when the version changes, all deployments have to be deleted and created again.
I propose some changes to have a switch to tell set-labels that it shouldn't set
.spec.selectors
. I have achieved this through theSetLabels
kind already defined:Considerations
I think that keeping backwards compatibility is very important. Therefore the option always defaults to true. Meaning if you change nothing, the functaionality doesn't change, even with this new feature. I haven't added this new functionality to the
ConfigMap
approach. This is because it would be harder to make this approach backwards compatible. The same with the imperative approach.I have added a new e2e test for this functionality. I don't think this small functionality merits a new example page, but i have expanded the main README.md for the function.