Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label-without-selector option for application kustomize source commonLabels #17328

Open
lets-call-n-walk opened this issue Feb 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@lets-call-n-walk
Copy link
Contributor

lets-call-n-walk commented Feb 27, 2024

Summary

Current kustomize application source only allows the default configuration of adding common labels, which applies said labels to object metadata, spec.selector, and spec.template.metadata. Kustomize provides configuration options to label resources without labeling the selector or template. See official documentation. Argocd should have some capability to ignore selectors/templates with commonLabels in its Kustomize application source.

Motivation

My company deploys >550 applications. If we want to add a common label to appsets for identification purposes with argocd, it also modifies the selectors, which are oftentimes immutable fields. This means for every label addition to our appsets, we would have to delete and resync hundreds of application resources. We would like a simple way to add common labels to our application resources for identification, without the overhead that comes with modifying the resource selectors.

Proposal

Kustomize command line implements the documented feature with the following:

kustomize edit add label --help
Adds one or more commonLabels to kustomization.yaml

Usage:
  kustomize edit add label [flags]

Examples:

		add label {labelKey1:labelValue1} {labelKey2:labelValue2}

Flags:
  -f, --force              overwrite commonLabel if it already exists
  -h, --help               help for label
      --without-selector   using add labels without selector option

Global Flags:
      --stack-trace   print a stack-trace on error

Because argocd builds kustomize through the commandline, I would like to add a boolean option to the application and applicationset template sources named labelWithoutSelector.
I would also like to be the one to contribute to this, as this would be my first time contributing to open source. (I have already made the said changes and tests on a local branch to see how easy it would be)

Example of what the application manifest would look like:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: example
  namespace: example
spec:
  project: example
  source:
    repoURL: git@github.example.com:example/example
    targetRevision:  main
    path: example
    kustomize:
      commonLabels:
        foo: bar
      labelWithoutSelector: true
  destination:
    name: example
    namespace: example
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
@ptr1120
Copy link

ptr1120 commented Feb 28, 2024

In addition commonLabels have been deprecated while labels offer now the same features but with configurable options for selectors see also

@lets-call-n-walk
Copy link
Contributor Author

lets-call-n-walk commented Feb 29, 2024

It appears that the Kustomize CLI has not yet been updated to utilize the new label API. The only instance where it incorporates this API is when the --without-selector argument is included. For Argo to effectively utilize kustomize edit add label and fully integrate the new label API, further development of the Kustomize CLI is required - that is, without completely changing how the kustomize source builds the application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants