argoproj / applicationset

The ApplicationSet controller manages multiple Argo CD Applications as a single ApplicationSet unit, supporting deployments to large numbers of clusters, deployments of large monorepos, and enabling secure Application self-service.
https://argocd-applicationset.readthedocs.io/
Apache License 2.0
587 stars 279 forks source link

Enhancement: ApplicationSet should support functions in template #447

Open Shane-Williamson opened 2 years ago

Shane-Williamson commented 2 years ago

Feature request

ApplicationSet should be able to support functions in the template section of the manifest. This should be generator-agnostic, although for our use-case, we're blocked by the scmGenerator.

Something like this pseudo-code:

template:
  metadata:
    name: {{ repository | replace "some-text" "" }}-{{ branch | replace "/" "-" | lower }}`

Use-case (as example): we want to be able to scan repos in our org that match a naming pattern for branches that match a naming pattern and deploy applications from those branches. The purpose is to support a fully automated gitops development process where developers can create specific branches in their repos and an instance of that app will be automatically deployed by ApplicationSet. This means that there will be several instances of the same app deployed in cluster so names need to be unique. After changes are merged and the branch is deleted, the application should then be deleted by ApplicationSet.

The lack of functions is blocking this in these ways:

  1. Combining the repo name with the branch name for uniqueness (e.g. {{ repository }}-{{ branch }} ) can exceed the character limit in k8s. The replace function would enable shortening the name by any matched string.
  2. We use Jira which only recognizes upper-case ticket identifiers (e.g. DEVOPS-1234). Atlassian has stated this is not something they will fix from the digging I've done. K8s does not allow upper-case resource names. So we either break Jira integration or break deployments.
  3. Our branch names have / in them which is an invalid character to k8s.
crenshaw-dev commented 2 years ago

Duplicate of https://github.com/argoproj/applicationset/issues/351 / https://github.com/argoproj/applicationset/issues/303? Potential fix here: https://github.com/argoproj/applicationset/pull/513