Skip to content

Commit

Permalink
helm 3.10.3 I hate you deeply
Browse files Browse the repository at this point in the history
This fixes the infamous: error calling tpl: cannot retrieve Template.Basepath from values inside tpl function

It does use .Values in templates to access values and pass $ root context to tpl
  • Loading branch information
TheoBrigitte committed Dec 10, 2024
1 parent 8aa6a06 commit 4b4c161
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
global:
resolve_timeout: 5m
{{- if .alertmanager.proxyURL }}
{{- if .Values.alertmanager.proxyURL }}
http_config:
proxy_url: {{ .alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
slack_api_url: "https://slack.com/api/chat.postMessage"
{{- else }}
slack_api_url: {{ .alertmanager.slackAPIURL }}
slack_api_url: {{ .Values.alertmanager.slackAPIURL }}
{{- end }}

route:
Expand All @@ -27,7 +27,7 @@ route:
group_wait: 30s
group_interval: 30s
repeat_interval: 15m
{{- if eq .managementCluster.pipeline "stable-testing" }}
{{- if eq .Values.managementCluster.pipeline "stable-testing" }}
- receiver: blackhole
matchers:
- cluster_type="workload_cluster"
Expand Down Expand Up @@ -84,7 +84,7 @@ route:
# Team Atlas Slack
- receiver: team_atlas_slack
matchers:
{{- if eq .managementCluster.pipeline "stable" }}
{{- if eq .Values.managementCluster.pipeline "stable" }}
- severity="notify"
{{- else }}
- severity=~"page|notify"
Expand Down Expand Up @@ -171,28 +171,28 @@ receivers:
http_config:
authorization:
type: GenieKey
credentials: {{ .monitoring.opsgenieApiKey }}
credentials: {{ .Values.monitoring.opsgenieApiKey }}
follow_redirects: true
enable_http2: true
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
url: https://api.opsgenie.com/v2/heartbeats/{{ .managementCluster.name }}/ping
url: https://api.opsgenie.com/v2/heartbeats/{{ .Values.managementCluster.name }}/ping

{{- if eq .managementCluster.pipeline "stable-testing" }}
{{- if eq .Values.managementCluster.pipeline "stable-testing" }}
- name: blackhole
{{- end }}

- name: falco_noise_slack
slack_configs:
- channel: '#noise-falco'
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
Expand All @@ -217,75 +217,75 @@ receivers:

- name: team_atlas_slack
slack_configs:
{{- if eq .managementCluster.pipeline "stable" }}
{{- if eq .Values.managementCluster.pipeline "stable" }}
- channel: '#alert-atlas'
{{- else }}
- channel: '#alert-atlas-test'
{{- end }}
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
actions: *slack-actions

- name: team_phoenix_slack
slack_configs:
{{- if eq .managementCluster.pipeline "stable" }}
{{- if eq .Values.managementCluster.pipeline "stable" }}
- channel: '#alert-phoenix'
{{- else }}
- channel: '#alert-phoenix-test'
{{- end }}
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
actions: *slack-actions

- name: team_bigmac_slack
slack_configs:
{{- if eq .managementCluster.pipeline "stable" }}
{{- if eq .Values.managementCluster.pipeline "stable" }}
- channel: '#alert-bigmac'
{{- else }}
- channel: '#alert-bigmac-test'
{{- end }}
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
actions: *slack-actions

- name: team_rocket_slack
slack_configs:
{{- if eq .managementCluster.pipeline "stable" }}
{{- if eq .Values.managementCluster.pipeline "stable" }}
- channel: '#alert-rocket'
{{- else }}
- channel: '#alert-rocket-test'
{{- end }}
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
Expand All @@ -294,32 +294,32 @@ receivers:
- name: team_shield_slack
slack_configs:
- channel: '#alert-shield'
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
actions: *slack-actions

- name: team_turtles_slack
slack_configs:
{{- if eq .managementCluster.pipeline "stable" }}
{{- if eq .Values.managementCluster.pipeline "stable" }}
- channel: '#alert-turtles'
{{- else }}
- channel: '#alert-turtles-test'
{{- end }}
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
Expand All @@ -328,13 +328,13 @@ receivers:
- name: team_tenet_slack
slack_configs:
- channel: '#alert-tenet'
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
Expand All @@ -343,21 +343,21 @@ receivers:
- name: team_honeybadger_slack
slack_configs:
- channel: '#alert-honeybadger'
{{- if .alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.slackAPIToken }}
http_config:
authorization:
type: Bearer
credentials: {{ .alertmanager.slackAPIToken }}
{{- if .alertmanager.proxyURL }}
proxy_url: {{ .alertmanager.proxyURL }}
credentials: {{ .Values.alertmanager.slackAPIToken }}
{{- if .Values.alertmanager.proxyURL }}
proxy_url: {{ .Values.alertmanager.proxyURL }}
{{- end }}
{{- end }}
send_resolved: true
actions: *slack-actions

- name: opsgenie_router
opsgenie_configs:
- api_key: {{ .monitoring.opsgenieApiKey }}
- api_key: {{ .Values.monitoring.opsgenieApiKey }}
tags: {{`{{ (index .Alerts 0).Labels.alertname }},{{ (index .Alerts 0).Labels.cluster_type }},{{ (index .Alerts 0).Labels.severity }},{{ (index .Alerts 0).Labels.team }},{{ (index .Alerts 0).Labels.area }},{{ (index .Alerts 0).Labels.service_priority }},{{ (index .Alerts 0).Labels.provider }},{{ (index .Alerts 0).Labels.installation }},{{ (index .Alerts 0).Labels.pipeline }},{{ (index .Alerts 0).Labels.customer }}`}}

inhibit_rules:
Expand All @@ -369,7 +369,7 @@ inhibit_rules:

- source_matchers:
- inhibit_kube_state_metrics_down=true
- cluster_id={{ .managementCluster.name }}
- cluster_id={{ .Values.managementCluster.name }}
target_matchers:
- cancel_if_mc_kube_state_metrics_down=true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{{`
{{ define "__alerturl" }}
`}}{{ .alertmanager.grafanaAddress }}{{`/alerting/Mimir/{{ .CommonLabels.alertname }}/find
`}}{{ .Values.alertmanager.grafanaAddress }}{{`/alerting/Mimir/{{ .CommonLabels.alertname }}/find
{{ end }}

{{ define "__dashboardurl" -}}
{{ if match "^https://.+" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}
{{ else }}
`}}{{ .alertmanager.grafanaAddress }}{{`/d/{{ (index .Alerts 0).Annotations.dashboard }}
`}}{{ .Values.alertmanager.grafanaAddress }}{{`/d/{{ (index .Alerts 0).Annotations.dashboard }}
{{ end }}
{{- end }}

{{ define "__queryurl" }}
`}}{{ .alertmanager.grafanaAddress }}{{`/alerting/Mimir/{{ .CommonLabels.alertname }}/find
`}}{{ .Values.alertmanager.grafanaAddress }}{{`/alerting/Mimir/{{ .CommonLabels.alertname }}/find
{{ end }}

{{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
data:
{{- /* Template all .helm-template files found in files/alertmanager with values under alertmanager key */ -}}
{{ range $path, $_ := .Files.Glob "files/alertmanager/*.helm-template" }}
{{ base $path | trimSuffix ".helm-template" }}: {{ tpl ($.Files.Get $path) $.Values | b64enc }}
{{ base $path | trimSuffix ".helm-template" }}: {{ tpl ($.Files.Get $path) $ | b64enc }}
{{ end }}

{{- /* Add all other non .helm-template files found in files/alertmanager */ -}}
Expand Down

0 comments on commit 4b4c161

Please sign in to comment.