Argo-cd: Support Application names more than 63 chars long

Created on 4 Aug 2020  路  4Comments  路  Source: argoproj/argo-cd

Summary

Add support argoproj application names of more than 63 chars. It already works pre-sync, but when argocd injects this label it is limited by the k8s label spec of 63 char max.

Motivation

Argocd requires unique application names to function. If you try to deploy the same app on multiple clusters and namespaces, we need to add metadata on the end so that it works (we use: {applicationname}.{ns}.{cluster} ).

The problem comes from the use of "application.instanceLabelKey", which is limited by the k8s label spec. Argocd uses the application name as it's value.

Proposal

  • Use a 63 char hash of the argocd.application name as the instanceLabelKey value, in stead of the name itself.
    or
  • use an annotation in stead of a label for the instanceLabelKey
enhancement

Most helpful comment

Potentially, since you guys already use : "crypto/sha256"
In GetAppInstanceLabelKey we could check the len of the label and if it's greater than 63, set it to something like :
label := sha256.Sum224([]byte(label)) which is a subset of sha256 and should be enough to avoid collisions.
We can even add : sha224- in front of the hash to make it clear that it's the hash of a name (which by coincidence, makes it a 63 chars label).

All 4 comments

This is a known limitation of our use of labels as a way of tracking resources.

use an annotation in stead of a label for the instanceLabelKey

This is technically possible, but would require some surgery to support.

how hard do you estimate the fix @jessesuen ?
replacing simply the value of the label with a fix hash of 63character is not possible without changing everything ?

Potentially, since you guys already use : "crypto/sha256"
In GetAppInstanceLabelKey we could check the len of the label and if it's greater than 63, set it to something like :
label := sha256.Sum224([]byte(label)) which is a subset of sha256 and should be enough to avoid collisions.
We can even add : sha224- in front of the hash to make it clear that it's the hash of a name (which by coincidence, makes it a 63 chars label).

I've made a draft PR here : https://github.com/argoproj/argo-cd/pull/4051

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rosscdh picture rosscdh  路  3Comments

peterbosalliandercom picture peterbosalliandercom  路  3Comments

turbotankist picture turbotankist  路  3Comments

estahn picture estahn  路  3Comments

clintberry picture clintberry  路  3Comments