helm: Can Helm support to ignore {{expr}} which is just for configuration but not render?
There is a use case: deploy Prometheus as StatefulSet and config alerting-rules as ConfigMap.
alerting-rules can take more detail on here: https://prometheus.io/docs/alerting/rules/#alerting-rules
it looks like:
IF node_memory_Active >= 1
FOR 1m
LABELS {
service = "k8s_metrics",
alertname = "InstanceMemoryOverload"
}
ANNOTATIONS {
summary = "Instance {{ $labels.instance }} memory overload",
description = "{{ $labels.instance }} memory overload for more than 1 minutes, now is {{ $value }}."
}
Can Helm support to ignore {{expr}} which is just for configuration but not render?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 44
- Comments: 25 (3 by maintainers)
Commits related to this issue
- Tried to escape with a solution found in https://github.com/helm/helm/issues/2798 Signed-off-by: Roland T. Lichti <rlichti@redhat.com> — committed to klenkes74/aws-egressip-operator by klenkes74 4 years ago
- fix: testing - https://github.com/helm/helm/issues/2798#issuecomment-326454957 — committed to GlueOps/platform-helm-chart-grafana-dashboards by venkatamutyala a year ago
- fix eso helm templating - see https://github.com/helm/helm/issues/2798 — committed to BryceCh/multicloud-gitops by BryceCh a year ago
A viable hack is to let Helm render the template as a raw string. Note the opening and closing curly bracket with a backtick:
The way to escape double curly brackets in Go templates is to use
{{ "{{" }}
. It’s not extremely difficult, just ugly.You can add
and will template properly
I ran into this same/similar problem awhile ago and solved it by embedding including the alerting rules as separate files, as
AFAIK it is extremely difficult to escape
{{ }}
in a go template, and slurping the files in from elsewhere is much simpler.you can also use printf for that:
{{ printf "{{ some value }}" }}
IMHO this thread was closed to early. Just because a workaround was found for something that should be enabled in helm itself via some metadata like
Where both of this evaluate to “” ofc.
Yes - there are workarounds but the original creator of this thread asked for a configuration for helm not a workaround for strings to trick helm. And I think it would be a great addition.
Its a feature request and should also be considered as such.
Thank you very much. That solved the big problem
I’m going to close this issue as we have two separate solutions to the problem, but please re-open if this hasn’t been resolved.
Hi,
Just for the persons how reach here and finding the way to use literal like “{{ xxxxx }}” in your helm value file. The snippet below solved my issue.
The helm rendered output look like this
This didn’t work for me. After banging my head for 2 days was able to make following work!
I can add to the chorus of confirmations that this still works.
And you may need it to get this to work:
https://www.vaultproject.io/docs/platform/k8s/injector/examples/
it works, thx
I have a similar use case to have a go style template in a config map. Right now helm is trying to evaluate the template and causing errors in the config map.
there is a better workaround and is using toJson
this avoids Go rendering the content of compute.json and puts the content there with the “{{variables}}” and everything.
be aware. Confimaps have a limitation of 1 MB. So do not abuse this. Otherwise, consider putting them on a repo and use something like this for GitLab (you can do it for any external URL / repo):