Interview Prep/Helm/Templating: Go Templates & Sprig

Can a template generate certificates, and should it?

AdvancedConceptTemplating: Go Templates & Sprig
Answer

Yes, Sprig has genCA, genSignedCert, genSelfSignedCert and genPrivateKey:

{{- $ca := genCA "shop-webhook-ca" 365 }}
{{- $cert := genSignedCert (printf "%s.%s.svc" (include "shop.fullname" .) .Release.Namespace) nil nil 365 $ca }}
tls.crt: {{ $cert.Cert | b64enc }}
tls.key: {{ $cert.Key | b64enc }}

It is common for admission webhook CAs, but every render produces a new cert, so upgrades rotate them, GitOps tools show permanent drift, and certificates expire silently. In production we prefer cert-manager to issue and rotate them.

All Helm questions Roadmap: Helm

More on Templating: Go Templates & Sprig