argo-cd
argo-cd copied to clipboard
cluster generate: ability to use not match
Summary
In the cluster generator of an applicationset, the ability to include all clusters minus specified clusters.
Motivation
I have an argo instance which installs common addons to all clusters which I add. This works except for one addon which I need to avoid installing on two clusters. For an actual use case: I install 'external-dns' and on each cluster and set it up using parameters in the applicationset to filter domains '{{name}}.k.home.net'. However, I have a couple clusters where I want a filter of 'k.home.net'. To do this I'd like to make an exception for two clusters when installing 'external-dns' (I'll set those up manually with a different filter), but go ahead and install all the other usual addons to all clusters.
I've heard I could match a label to all clusters we do want to add, if we imagine doing this with 100 clusters, that would mean adding a label to 98 clusters in order to exclude 2. Seems more practical to specify the two somehow.
Proposal
There are probably multiple ways to add this, maybe:
- in addition to 'matchLabels' you could have 'unMatch', 'notMatchLabels' or 'ignoreLabels'
- or maybe allow a '!' character
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: external-dns
namespace: argocd-global
spec:
generators:
- clusters:
selector:
matchLabels:
argocd.argoproj.io/secret-type: cluster
argocd.argoproj.io/cluster-name: !an-ignored-cluster
unMatchLabels:
argocd.argoproj.io/cluster-name: an-ignored-cluster
notMatchLabels:
argocd.argoproj.io/cluster-name: an-ignored-cluster
ignoreLabels:
argocd.argoproj.io/cluster-name: an-ignored-cluster
How about using matchExpressions with the NotIn operator?
After more study, along with automation, it's easy enough to tag everything where I want something installed. Closing as not needed, at least for my use case.