Skip to content

Commit

Permalink
Add deprecation warning for opencost external secret
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <pete.wall@grafana.com>
  • Loading branch information
petewall committed Apr 25, 2024
1 parent 9b39064 commit 2986a2f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/k8s-monitoring/ci/ci-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ opencost:
extraEnv:
INSECURE_SKIP_VERIFY: "true"
prometheus:
secret_name: prometheus
existingSecretName: prometheus
username_key: username
password_key: password
external:
Expand Down
21 changes: 21 additions & 0 deletions charts/k8s-monitoring/templates/_deprecations.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,25 @@ For more information, see https://github.com/grafana/k8s-monitoring-helm/tree/ma
(index .Values.metrics "agent") }}
{{ fail "\n\nAs of k8s-monitoring Chart version 1.0, Grafana Agent has been replaced with Grafana Alloy.\nThese sections in your values file will need to be renamed:\n grafana-agent --> alloy\n grafana-agent-events --> alloy-events\n grafana-agent-logs --> alloy-logs\n grafana-agent-profiles --> alloy-profiles\n metrics.agent --> metrics.alloy\n\nFor more information, see https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring#breaking-change-announcements" }}
{{- end -}}

{{/*
v1.0.1: OpenCost changed how to reference an external secret
As of k8s-monitoring Chart version 1.0.1, OpenCost changed how to reference an external secret.
Please rename:
opencost:
opencost:
prometheus:
secret_name: prometheus-k8s-monitoring
To:
opencost:
opencost:
prometheus:
existingSecretName: prometheus-k8s-monitoring
For more information, see https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring#breaking-change-announcements
*/}}
{{- if .Values.opencost.opencost.prometheus.secret_name }}
{{ fail "\n\nAs of k8s-monitoring Chart version 1.0.1, OpenCost changed how to reference an external secret.\nPlease rename:\nopencost:\n opencost:\n prometheus:\n secret_name: prometheus-k8s-monitoring\nTo:\nopencost:\n opencost:\n prometheus:\n existingSecretName: prometheus-k8s-monitoring\n\nFor more information, see https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring#breaking-change-announcements" }}
{{- end -}}
{{- end -}}
20 changes: 20 additions & 0 deletions tests/spec/deprecation-warning_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ These sections in your values file will need to be renamed:
grafana-agent-profiles --> alloy-profiles
metrics.agent --> metrics.alloy
For more information, see https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring#breaking-change-announcements'
End
End

Describe 'Using older OpenCost secret_name in values file'
It 'prints a friendly error message'
When call helm template k8smon ../charts/k8s-monitoring -f "spec/fixtures/deprecated-opencost-secret_values.yaml"
The status should be failure
The error should include 'As of k8s-monitoring Chart version 1.0.1, OpenCost changed how to reference an external secret.
Please rename:
opencost:
opencost:
prometheus:
secret_name: prometheus-k8s-monitoring
To:
opencost:
opencost:
prometheus:
existingSecretName: prometheus-k8s-monitoring
For more information, see https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring#breaking-change-announcements'
End
End
Expand Down
23 changes: 23 additions & 0 deletions tests/spec/fixtures/deprecated-opencost-secret_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cluster:
name: using-grafana-cloud-prometheus-component

externalServices:
prometheus:
host: https://prometheus.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"
loki:
host: https://loki.example.com
basicAuth:
username: 12345
password: "It's a secret to everyone"

opencost:
opencost:
prometheus:
secret_name: prometheus
username_key: username
password_key: password
external:
url: https://prometheus.example.com/api/prom

0 comments on commit 2986a2f

Please sign in to comment.