Repository navigation
Description
Let me start with describing the issue I am trying to solve.
Many (official) Helm charts allow you to specify annotations on object descriptions (e.g. ingress descriptions). Ingress controllers support f.e. authentication by looking at annotations on the ingress objects. E.g. ingress.kubernetes.io/auth-type and ingress.kubernetes.io/auth-secret. This ingress.kubernetes.io/auth-secret annotation defines the name of the k8s secret containing the username/password for basic auth.
But the charts don't offer a way to create the secret object. If the chart did include a secret template, you could have used the helm secret-plugin to render.
Manually creating the secrets feels bad...
Another option would be to create a helmfile release based on a local chart, having this local chart containing the secret template. Imho it would be a lot cleaner if this secret would be part of the same Helm release as f.e. the ingress object.
This makes me wonder if it is sensible to have a helmfile feature to merge arbitrary local Helm templates into the chart before rendering.
helmfile.yaml:
releases:
- name: myprometheus
chart: stable/prometheus
values:
- values.yaml
secrets:
- secret/my-prometheus-secret.yaml
templates:
- templates/basic-auth-secret.yamlvalues.yaml:
server:
ingress:
enabled: true
annotations:
ingress.kubernetes.io/auth-type: "basic"
ingress.kubernetes.io/auth-secret: prometheus-basic-auth-secrettemplates/basic-auth-secret.yaml:
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: prometheus-basic-auth-secret
labels:
app: {{ template "prometheus.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
data:
auth: {{ .Values.myPrometheusSecret | b64enc | quote }}Feature request #392 describes how to get secrets from different backends/sources (Helm secret plugin / Vault / AWS / KeyHub ❤️ ) into helmfile. This feature request is about a way to get those secrets into k8s as Secrets as part to the release they belong to.
Dream mode
Being able to add arbitrary Helm templates would allow me to do the following.
Define my own custom resource description containing all the metadata I need to sync a secret from a backend/source to a k8s Secret. A custom k8s controller would then be able to sync the secrets between backend/source and k8s. So changing the secret in the central secret store of truth would take effect without the need to do a deployment (helmfile sync).
And... deployers/releasers don't need access to the secrets themselves, as long as they know the metadata. Only the k8s controller requires access to the secrets.
Activity
mumoshu commentedon Mar 20, 2019
@sboschman Hey! Thanks for the request, and the detailed explanation.
If you don't mind paraphrasing, you want adhoc resources to be injected into the helm release, right?
If so - yes, I felt similar frustration while using another charts, and wondered how I could fully manage all those with helm.
That being said, I was thinking that using the
incubator/rawchart would be a potential solution here?https://github.com/helm/charts/tree/master/incubator/raw
With the chart, instead of:
You'll write:
A downside of this approach is that you need to inject the prom secret as an envvar OR maintain not only the secret value but the whole secret object within a
secret.yamlto be consumed by helmfile'ssecrets:field.For that, I was considering to enhance the
incubator/rawchart to accepttemplatessettings, that can be used like:I can send a PR to
incubator/rawif that makes sense (or if you could do so I'd greatly appreciate it :)mumoshu commentedon Mar 21, 2019
PTAL: helm/charts#12422
mumoshu commentedon Mar 22, 2019
incubator/raw0.2.0 has been released :)sboschman commentedon Mar 25, 2019
@mumoshu Thanks for your elaborate reply.
Yes, it is basically about injecting adhoc / arbitrary resources into the release of a chart. Merging them into the release itself would be great, but I can live with the
incubator/rawidea. That saves a lot of boiler plate chart stuff compared to including a local chart.I have used envvar (required in helm template) for secrets before, and that is less than ideal for sure. Encrypting entire resource objects is also a pain, as they basically become unreadable to us poor humans.
Being able to template stuff into
incubator/rawlooks like a nice solution to all this. 👍I see you beat me to making changes to
incubator/raw, going to test them out asap. Thanks for the work!sgandon commentedon Mar 26, 2019
I have used the
incubator/rawsuccessfully and that is a nice idea.here is an example
where I have a pod manifest defined in the docker-image-change-watcher.yaml file.
One issue though is that the
rawchart creates a configmap resource for ci that is present during the chart install :(.sboschman commentedon Mar 27, 2019
Do you get the ci configmap using the
templatesoption or did you see it using theresourcesoption @sgandon ?I get the following results, using helmfile v0.47.0. Using the
templatesoption seems to overwrite the default with the ci configmap.Use templates (:+1:):
Use resources (:-1:):
Use resources, and explicitly disable templates (:+1: 1:):
@mumoshu Can we circumvent ci in some other way (https://github.com/helm/charts/blob/master/incubator/raw/values.yaml#L68) ? Everyone using the
resourceswithout the newtemplatesgets the ci configmap I think.sgandon commentedon Mar 27, 2019
indeed using the
templateis fine, I did try withresourcesand this is where I saw the ci-configmap.mumoshu commentedon May 13, 2019
helm/charts#13633 should fix the ci-configmap issue.
unacceptable commentedon Jun 25, 2020
I still think that this core ask is a good idea. Consider for a moment a helm chart like Jenkins. It might be desirable to store the CasC in a config map to limit the size of the values file:
https://github.com/helm/charts/blob/75a1020b6cce44cba3df11999b277e5c2c43db84/stable/jenkins/values.yaml#L603-L609
then to apply said config map when changing the chart:
Where the values file will look something like this:
While this solution works, it's not as clean as it could be IMHO, as it's impossible to review diffs in the CasC which can lead to problems if some Junior Dev or Old School admin is trying to do some ClickOps.
Maybe there's a way to copy a template to the chart directory using a hook. If so please lemme know and that would solve my issue with the diffs, and I think it would solve the core of this issue. Again not sure if that last part is possible.
KarstenSiemer commentedon Oct 15, 2020
I did it like this:
the secret is looking like this:
mxmorin commentedon Mar 24, 2021
incubator/raw is now deprecated : https://github.com/helm/charts/tree/master/incubator/raw
mumoshu commentedon Mar 24, 2021
Hey everyone! I was recently playing around with the idea of "a helmfile-builtin raw-chart-like feature" 25baebe. It turn any local directory containing "*.yaml.gotmpl" into a temporary helm chart by rendering each template with Helmfile's template context/funcs/data. Would it help?
feat: Helmfile renders *.yaml.gotmpl in a K8s manifests/kustomization…
feat: Helmfile renders *.yaml.gotmpl in a K8s manifests/kustomization…
feat: Helmfile renders *.yaml.gotmpl in a K8s manifests/kustomization…
SeWieland commentedon Nov 4, 2021
I would really like that feature in order to be able to add k8s hooks as resources to the charts (instead of using the helmfile hooks directly)..
This would be a really powerful feature IMO 👍
p3lim commentedon Dec 13, 2021
Any chance this can be considered again, since incubator/raw is now deprecated?
It seems like this request was pretty much turned down due to that workaround, while being limiting in terms of integrating with the chart.
hlesesne commentedon Aug 31, 2022
SO many charts don't include netpols, yet almost every production deployment we have requires one. The ability to add additional templates at release would be extremely helpful.