Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix consul-telemetry-collector deployment templates #3184

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3184.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
consul-telemetry-collector: fix args to consul-dataplane when global.acls.manageSystemACLs
```
3 changes: 1 addition & 2 deletions charts/consul/templates/telemetry-collector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,12 @@ spec:
- -login-auth-method={{ template "consul.fullname" . }}-k8s-auth-method
{{- if .Values.global.enableConsulNamespaces }}
{{- if .Values.syncCatalog.consulNamespaces.mirroringK8S }}
- -login-namespace="default"
- -login-namespace=default
{{- else }}
- -login-namespace={{ .Values.syncCatalog.consulNamespaces.consulDestinationNamespace }}
{{- end }}
{{- end }}
{{- if .Values.global.adminPartitions.enabled }}
- foo
- -login-partition={{ .Values.global.adminPartitions.name }}
{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,12 @@ spec:
- -login-auth-method={{ template "consul.fullname" . }}-k8s-auth-method
{{- if .Values.global.enableConsulNamespaces }}
{{- if .Values.syncCatalog.consulNamespaces.mirroringK8S }}
- -login-namespace="default"
- -login-namespace=default
{{- else }}
- -login-namespace={{ .Values.syncCatalog.consulNamespaces.consulDestinationNamespace }}
{{- end }}
{{- end }}
{{- if .Values.global.adminPartitions.enabled }}
- foo
- -login-partition={{ .Values.global.adminPartitions.name }}
{{- end }}
{{- end }}
Expand Down
38 changes: 37 additions & 1 deletion charts/consul/test/unit/telemetry-collector-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1212,4 +1212,40 @@ MIICFjCCAZsCCQCdwLtdjbzlYzAKBggqhkjOPQQDAjB0MQswCQYDVQQGEwJDQTEL' \
--set 'ui.enabled=false' \
--set 'global.experiments[0]=resource-apis' \
.
}
}

#--------------------------------------------------------------------
# Namespaces

@test "telemetryCollector/Deployment: namespace flags when mirroringK8S" {
cd `chart_dir`
local object=$(helm template \
-s templates/telemetry-collector-deployment.yaml \
--set 'telemetryCollector.enabled=true' \
--set 'telemetryCollector.image=bar' \
--set 'global.enableConsulNamespaces=true' \
--set 'global.acls.manageSystemACLs=true' \
--set 'syncCatalog.consulNamespaces.mirroringK8S=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec' | tee /dev/stderr)

local actual=$(echo $object | jq -r '.containers[1].args | any(contains("-login-namespace=default"))' | tee /dev/stderr)
[ "${actual}" = 'true' ]
}

@test "telemetryCollector/Deployment: namespace flags when syncCatalog" {
cd `chart_dir`
local object=$(helm template \
-s templates/telemetry-collector-deployment.yaml \
--set 'telemetryCollector.enabled=true' \
--set 'telemetryCollector.image=bar' \
--set 'global.enableConsulNamespaces=true' \
--set 'global.acls.manageSystemACLs=true' \
--set 'syncCatalog.consulNamespaces.mirroringK8S=false' \
--set 'syncCatalog.consulNamespaces.consulDestinationNamespace=fakenamespace' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers' | tee /dev/stderr)

local actual=$(echo $object | jq -r '.[1].args | any(contains("-login-namespace=fakenamespace"))' | tee /dev/stderr)
[ "${actual}" = 'true' ]
}
40 changes: 40 additions & 0 deletions charts/consul/test/unit/telemetry-collector-v2-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1348,3 +1348,43 @@ MIICFjCCAZsCCQCdwLtdjbzlYzAKBggqhkjOPQQDAjB0MQswCQYDVQQGEwJDQTEL' \
--set 'telemetryCollector.image=bar' \
.
}

#--------------------------------------------------------------------
# Namespaces

@test "telemetryCollector/Deployment(V2): namespace flags when mirroringK8S" {
cd `chart_dir`
local object=$(helm template \
-s templates/telemetry-collector-v2-deployment.yaml \
--set 'ui.enabled=false' \
--set 'global.experiments[0]=resource-apis' \
--set 'telemetryCollector.enabled=true' \
--set 'telemetryCollector.image=bar' \
--set 'global.enableConsulNamespaces=true' \
--set 'global.acls.manageSystemACLs=true' \
--set 'syncCatalog.consulNamespaces.mirroringK8S=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec' | tee /dev/stderr)

local actual=$(echo $object | jq -r '.containers[1].args | any(contains("-login-namespace=default"))' | tee /dev/stderr)
[ "${actual}" = 'true' ]
}

@test "telemetryCollector/Deployment(V2): namespace flags when syncCatalog" {
cd `chart_dir`
local object=$(helm template \
-s templates/telemetry-collector-v2-deployment.yaml \
--set 'ui.enabled=false' \
--set 'global.experiments[0]=resource-apis' \
--set 'telemetryCollector.enabled=true' \
--set 'telemetryCollector.image=bar' \
--set 'global.enableConsulNamespaces=true' \
--set 'global.acls.manageSystemACLs=true' \
--set 'syncCatalog.consulNamespaces.mirroringK8S=false' \
--set 'syncCatalog.consulNamespaces.consulDestinationNamespace=fakenamespace' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers' | tee /dev/stderr)

local actual=$(echo $object | jq -r '.[1].args | any(contains("-login-namespace=fakenamespace"))' | tee /dev/stderr)
[ "${actual}" = 'true' ]
}
Loading