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

correct prometheus port and scheme annotations if tls is enabled #2782

Merged
merged 3 commits into from
Aug 29, 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/2782.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
helm: Update prometheus port and scheme annotations if tls is enabled
```
6 changes: 6 additions & 0 deletions charts/consul/templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ spec:
{{- if (and .Values.global.metrics.enabled .Values.global.metrics.enableAgentMetrics) }}
"prometheus.io/scrape": "true"
"prometheus.io/path": "/v1/agent/metrics"
{{- if .Values.global.tls.enabled }}
"prometheus.io/port": "8501"
"prometheus.io/scheme": "https"
{{- else }}
"prometheus.io/port": "8500"
"prometheus.io/scheme": "http"
{{- end }}
{{- end }}
spec:
{{- if .Values.server.affinity }}
Expand Down
35 changes: 35 additions & 0 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,41 @@ load _helpers
[ "${actual}" = "/v1/agent/metrics" ]
}

@test "server/StatefulSet: when global.metrics.enableAgentMetrics=true, adds prometheus scheme=http annotation" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.metrics.enabled=true' \
--set 'global.metrics.enableAgentMetrics=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations."prometheus.io/scheme"' | tee /dev/stderr)
[ "${actual}" = "http" ]
}

@test "server/StatefulSet: when global.metrics.enableAgentMetrics=true and global.tls.enabled=true, adds prometheus port=8501 annotation" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.metrics.enabled=true' \
--set 'global.metrics.enableAgentMetrics=true' \
--set 'global.tls.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations."prometheus.io/port"' | tee /dev/stderr)
[ "${actual}" = "8501" ]
}

@test "server/StatefulSet: when global.metrics.enableAgentMetrics=true and global.tls.enabled=true, adds prometheus scheme=https annotation" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.metrics.enabled=true' \
--set 'global.metrics.enableAgentMetrics=true' \
--set 'global.tls.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations."prometheus.io/scheme"' | tee /dev/stderr)
[ "${actual}" = "https" ]
}

#--------------------------------------------------------------------
# config-configmap

Expand Down