helmify
helmify copied to clipboard
Semi-Bug: CRDs with ``{{}}`` cause issues with helm, if CRD templating is enabled
Issue
Sometimes upstream CRDs have things like {{ .cluster.name }}-{{ .random }} in their description fields (like the ClusterClass CRD of cluster-api, see bellow), which should be present as-is in the final helm output / installation. But because {{ and }} are interpreted by helm, that leads to errors during templating.
Desired solution
Have helmify detect usage of {{}} in the provided manifests and replace them with
{{`{{
and
}}`}}
respectively. As shown bellow in the workaround.
How to reproduce Create chart
curl -sL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.7.0/core-components.yaml | \
go run github.com/arttor/helmify/cmd/[email protected] -vv
and then try to render the generated chart
$ helm template .
zsh: correct 'template' to 'templates' [nyae]? n
Error: template: chart/templates/clusterclass-crd.yaml:679:74: executing "chart/templates/clusterclass-crd.yaml" at <.cluster.name>: nil pointer evaluating interface {}.name
Use --debug flag to render out invalid YAML
Workaround
exists by wrapping the {{}} as part of the pipeline
curl -sL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.7.0/core-components.yaml | \
sed -e 's@{{@{{`{{@g' -e 's@}}@}}`}}@g' | \
go run github.com/arttor/helmify/cmd/[email protected] -vv