-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Summary
The ApplicationSet clusters generator is a great way to use labels to select a set of clusters. However, it is very hard to do reverse selections where you can choose a set but exclude specific items. You can use a single selector that inverses a label but it doesn't work for multiple sets of labels
Motivation
We have an app of apps deployment setup, that deploys to an ever-growing set of clusters. These clusters have multiple labels with different dimensionality. Some of the customers using those clusters might choose to not want some applications installed to lower the resource usage (eg, cpu/memory, or IP usage in daemonsets) or features enabled. This could be used, for example, to not install a daemonset service where the service won't be used at all, saving N (nodes) number of IPs in the process, or turning off features that interfere with some elements in specific clusters.
Proposal
I propose adding a field to the clusters generator which can refine the selector field and remove any cluster in the generated list:
spec:
generators:
- clusters:
selector:
matchExpressions:
- key: labelA
operator: Exists
- key: labelI
operator: Exists
- key: labelX
operator: Exists
excludeSelectors:
- matchLabels:
labelA: "b"
labelI: "j"
- matchExpressions:
- key: labelA
operator: In
values:
- "c"
- key: labelI
operator: In
values:
- "j"
- key: labelX
operator: In
values:
- "y"in this case, the labels could be:
labelA: [b,c]
labelI: [j,k]
labelX: [y,z]
In this case, if we created all clusters in this set of labels combinated, the resulting clusters where the Applciation would be renderd would be:
b-y-k
b-z-k
c-y-k
c-z-j
c-z-k
and the ones excluded would be:
b-z-j
b-y-j
c-y-j