Open pokgak opened 1 year ago
Also having the same problem. In fact, is there any reason not to have every kustomize top level field available by default? https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/
To echo the earlier comments on this issue, the additional of the labels
configuration option to Argo CD Application kustomize fields would be very useful to our platform team. Plus, commonLabels
have been deprecated: https://github.com/kubernetes-sigs/kustomize/pull/5464
To be clear, this can be achieved now using new patches
or components
?
To be clear, this can be achieved now using new
patches
orcomponents
?
Indeed, I had missed that the patches
Kustomize option was recently added to the Argo CD Application in v2.9.0. However, it would be more convenient and intuitive if the labels
Kustomize option was also added. Thanks for the heads up on using patches
for now.
Good to know patches is available but it can make config more polluted
labels
already is a Kustomize builtin transformer
Please also support replacements
It behaves more intuitively when it is top-level and not embedded in a component
I had this in my previous kustomize config, processed by envsubst instead of Argo CD, to add an environment label that's not included in selectors.
namespace: $ENVIRONMENT
labels:
- pairs:
environment: $ENVIRONMENT
includeTemplates: true
When I switched to an Argo CD application created by Terraform. It was rather disappointing that I gained the ability to set the namespace
directly from Terraform variables but could not do the same for adding labels that were not included in selectors.
Haven't tested it myself, but can you directly use the transformers instead of the top level option?
e.g.
Summary
Expose the kustomize
labels
configuration options in kustomization.yaml to allow adding labels to resources but skips adding to the matchLabels and selector fields in resources. The commonLabels options automatically adds the labels to both matchLabels and selector fields and there is no way to turn it off. This prevents using a dynamic value for the label as the matchLabels field is immutable and cannot be changed once created.The label configuration options is better since it allow users to configure whether or not to add the label to the selector and template.
Motivation
I'm currently reading the image tag through ApplicationSet templating using git files generator. The image tag is read from a file and passed to the application using kustomize
images
configuration options. Using the same image tag value, I also want to add a label to my Deployment resource.Using the
commonLabels
configuration option, it also adds the label to the matchSelector. Since my image tag value always changes, it will produce error when syncing since the matchLabel field is actually immutable and cannot be changed once created.The
labels
configuration option is the better way to achive what I'm trying to do but it is not exposed by ArgoCD Application resource as part of the kustomize configuration option currently.Proposal
Add new
labels
configuration option to ArgoCD Application kustomize fields.Documentation on kustomize
labels
: https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/labels/