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

Error when to use encryptionSecret and prometheus alertManager Template #4808

Open
ffjlabo opened this issue Mar 7, 2024 · 2 comments
Open
Labels
kind/bug Something isn't working

Comments

@ffjlabo
Copy link
Member

ffjlabo commented Mar 7, 2024

What happened:
When we tried to deploy kube-prometheus-stack by using PipeCD, plan preview failed like this↓

Add_kustomization_file_by_ffjlabo_·_Pull_Request__7_·_ca-dp_ffjlabo-dev

What you expected to happen:

We want to succeed to do a plan preview.

How to reproduce it:

  • Register k8s app with a helm chart kube-prometheus-stack
  • use both secret management (from PipeCD) and custom alert template in values.yaml like below↓

values.yaml

alertmanager:
...
  config:
    receivers:
    - name: 'pagerduty-notifications'
      pagerduty_configs:
      - service_key: {{.encryptedSecrets.key}}
  templateFiles:
     template_2.tmpl: |-
       {{ define "slack.custom.v2.text" }}
       {{ range .Alerts }}
         {{ if eq .Status "firing" }}{{ .Annotations.description }}{{else}}{{ .Annotations.resolved_description }}{{end}}
       {{ end }}
       {{ end }}

       {{ define "slack.custom.v2.title" }} [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }} {{ .GroupLabels.severity }}] {{ .GroupLabels.alertname }} {{ end }}

Environment:

  • piped version:
  • control-plane version:
  • Others:
@ffjlabo ffjlabo added the kind/bug Something isn't working label Mar 7, 2024
@ffjlabo
Copy link
Member Author

ffjlabo commented Mar 7, 2024

This happens because the custom alert template is parsed as Golang's text/template when parsing the encryptionSecret (from PipeCD).

@ffjlabo
Copy link
Member Author

ffjlabo commented Mar 7, 2024

Workaround:

  1. Use a Secret resource for .encryptedSecrets.key and don't use it on a file.
  2. Surround the part of the alert templating string by {{``}}. The surrounded part is parsed as just a string in Golang's text/template
    ref: Can Helm support to ignore {{expr}} which is just for configuration but not render? helm/helm#2798 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant