argoproj / argoproj/argo-cd

matchLabels selector doesn't allow dots in the name of the key

Open
#11,664 2 comments 0 reactions 0 assignees View on GitHub
bug component:application-sets
Dominant language
Go
Stars
24.2k
Forks
7.8k
Avg merge
1d 6h
Merged PRs (30d)
239

Description

**Describe the bug**

I'm using ApplicationSets to conditionally deploy resources to clusters.
For example, I would like to deploy a web application only on clusters that have the webApp.enabled property set to "true".

I'm using the matchLabel selector to set the condition, however it seems it doesn't support dots in key names.

**To Reproduce**

Here's a sample definition of a cluster (`clusters/test.yaml`):
```
---
cluster:
name: test-01
namespace: dev
virtualIp: 10.10.10.1
webApp:
enabled: "true"
values: |
service:
type: LoadBalancer
```

And the corresponding ApplicationSet, which doesn't work -- no Application gets created:
```
---
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: web-app
spec:
goTemplate: true
syncPolicy:
preserveResourcesOnDeletion: false
generators:
- git:
repoURL: https://gitlab.com/test/test.git
revision: main
files:
- path: clusters/*.yaml
selector:
matchLabels:
webApp.enabled: "true"
template:
metadata:
name: '{{.cluster.name}}-web-app'
spec:
project: default
source:
repoURL: https://gitlab.com/test/test.git
targetRevision: main
path: addons/web
helm:
values: '{{.webApp.values}}'
destination:
server: 'https://{{.cluster.virtualIp}}:6443'
namespace: default
syncPolicy:
syncOptions:
- ServerSideApply=true
```

I was able to work around by putting the key at the root at the document (`webAppEnabled`), however I would prefer to have it part of the webApp object. The following definition works:
```
---
cluster:
name: test-01
namespace: dev
virtualIp: 10.10.10.1
webAppEnabled: "true"
webApp:
values: |
service:
type: LoadBalancer
```
```
---
<..>
generators:
- git:
repoURL: https://gitlab.com/test/test.git
revision: main
files:
- path: clusters/*.yaml
selector:
matchLabels:
webAppEnabled: "true"
<..>
```

Am I missing something here, or is this not supported by the ApplicationSet controller?

**Expected behavior**

I would expect the ApplicationSet controller to accept dots in the name of the key, as it is possible in Kubernetes.

**Version**

```shell
argocd-server: v2.5.4+86b2dde
```

Contributor guide

Open the contributing guide

Research direction

Start with the ApplicationSet controller's Git generator and its matchLabels selector handling, using clusters/test.yaml and the provided ApplicationSet as the reproduction. Compare the dotted webApp.enabled key with the working webAppEnabled case, then verify that an Application is created for the dotted key without regressing the existing selector behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
ci-cd, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.