Repository navigation
Description
More of a feature request as I haven't fleshed out all the details yet.
Right now the only way I can configure config maps and secrets from files is to copy entire file contents (and base 64 for secrets) into the values files or --set, its a bit awkward.
Lets say I have an RSA key, at the moment I base64 this, strip whitespace and put it into my values file:
rsaPrivateKey: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBdUcydDRBZ2dydXl3WjFKa2o4azBWZ1c3ak1vTlhoRVVMSG1mbEpWRFFJbmZTRVBtCnZaWGlYUHRaOVA0VGdwLzQzYmY1MXIvSGt6NVhnbjBlR2FkQlJlZUIxSUxyRXI3N2M5ZXMyenJCWmJUcWZ3UHoKNVNZNzdraXBZVURkczVEOVlsWnUyQk5sMFJzUGpUWWJQOCtvbnNXeVVyNXc2L0cxNEZTK0dnWTA2bGpyTVdPbwpjOVA5dWVqbXlZYitNMUgrMGR4SWl4Wkg5TndBcnJ1RVZJVHlxVGJnaE9tYUhPK1lGUWlySG5XNjk2U01EbmozCnVja21tRTlwS3kwQkk0eUlHdnRIdWJRYTh3U21TMkw0RTA3Y1pXdzkrMW5LdU00Z2E1bStVL3U1WTJSOGJzSm4KVjg5a2ZFVFlVUUF3YUxVVTZySE44UFBlUFZvc3dWWTNjd1kyRXdJREFRQUJBb0lCQUVCWnJLaVZ6V21ibG5XRwpyeVhvYTRWMFhKdGtTTVBBcTh4VTU1UjlmRWpCa3BIeGQwcEJTUWx1ZmxYWWJWQlBweE1keFdQajZLdjh2YVgvCktBaUZibVlJd0NrNVFQSjZodHhGcmIrVXdiUk9LdUFFcmc0UGlDdTlXTFJoWUxudDVpdHd3eDVMcm1RRzBDZFMKY0xHVU1GNnQxbW0rbjBJRVJaU3ZuT0VSdDFibzlVZUE4dlduRjJPU2ZpM2pIWi8zdWFuZmdwcVh1eFVtN202YgplU3cwTDYxVGpLRFU1THBKNDJFcjlJaGRpbG83eXdoREszbTN0ZHNlcS9FY3ltL1I4ZGkwRDFUREEvdTFib3FpCmdRM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lKcE9mTkJZYm9pQlJBL2ZORU1HakNzNUo4SzVlOWlVMG44a1N3NXJlSVNySG5WYy9HckhZSW8KWkxsdDVVdk01bDJ5TGFZRVBRUWpOeGErd05SeUVaemhuZlhGV05kSndRNFdYSVd5WUNmU0FFSGh0UTRnbUZ1RgphczNUZHNqNjU2VGp4dlg0MVU3T21OalVZc0FmYVlQTFN5bzAxM1FjR0JUelBYYlo3R0tUCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg=="I know we have access to (.Files.Glob "foo/*").AsConfig and (.Files.Glob "bar/*").AsSecrets, but this is restricted to files inside the chart.
Perhaps we could use go template engine on the value file itself, like:
rsaPrivateKey: {{ (.Files.Glob "*.key.pem").AsSecrets }}This would give helm more flexibility, but also more complexity. The functionality could more restricted than whats in chart template files, perhaps even with a different syntax/engine. I'm not sure how it would work with relative paths, that is something we would have to figure out.
I have a feeling this was what #1662 was trying to get across, but I'm not sure. Has anyone else felt like this is needed?
P.S I am so happy with helm, its a great tool and I think you guys are doing a great job.
Activity
technosophos commentedon Dec 23, 2016
Sorry, may answer is a little disjointed because you raised several interesting things. I'm not totally sure I understand what you're asking, but I'll do my best.
First, the problem you raise is an interesting one that we want to solve better than we are today.
Second, we will probably never support running the template engine over
values.yamlbecause it generates substantial cognitive complexity. It also allows user to inject templates into a sealed chart, which can cause problems.Third, you gave me an interesting idea. The reason you cannot access files outside of the chart is because chart rendering is done on Tiller (mainly to ensure 100% reproducibility). And only files sent as part of the chart are available. Now, one thing you just brought up that I never thought about before is making it possible to pass files into a chart at install time. Maybe something like
helm install --extra-files *.key.pem .... As long as those files weren't templates, it would not violate our stability guidelines, then they would be available to the chart on the server. Would that be useful?syhol commentedon Dec 23, 2016
Yes! This is just what I need. Thanks for making sense of my issue. I can get by without this but I think it could be useful it many places, like mysql /docker-entrypoint-initdb.d files and nginx vhosts.
technosophos commentedon Dec 23, 2016
I'm going to rename the issue and drop it into the feature triage queue for 2.3.
[-]proposal: Better way use files in config maps and secrets[/-][+]proposal: import file(s) during `helm install`[/+]tallpauley commentedon Jan 9, 2017
Passing files through --extra-files sounds like a solution, but to me this seems like a sneaky backdoor way to get additional input into the release. I guess I see values.yml (and --set) as sort of the "interface" in which inputs are passed to helm. What I've been doing is just
helm install --set "value=cat file | base64`. Why can't the command-line client do something similar?I think it would be nice to have a syntax like
helm install --file-set value=config.jsonor something of the like. Then in the template you justb64decthe value if its a configmap, or leave it if its a secret.I guess I like passing files via Values, since it is a singular, documentable way to pass values into a chart. With
--extra-files, where would you document this file that your chart needs as input? I'm not totally against the idea, I'm just trying to imagine how this would work.I think an advantage of the
--extra-filesapproach though is that you could have a default file. For example you have a defaultmy.cnf, which can be overridable by--extra-files my.cnf=myconf.cnf. Whereas with the other approach I suggested, the entire default file would have to be inside Values.cnf, which would suck.At the end of this self dialogue, I think --extra-files might be quite nice :) I suppose one could document these required or optional files in values.yml
syhol commentedon Jan 16, 2017
After a little research...
TLDR:- Massive strings in ConfigMap templates is a fairly common pattern(/problem)
Looking at these suggests there are use cases for injecting files as value strings:
Also looking at these suggests there are use cases for templating in non kubernetes files (out of scope for this proposal):
So I think this is still a valid proposal.
Moving forward...
@tallpauley I love the
--file-setidea but I agree it would be nice to have a default file. What if every file in./mychart/values/*gets converted to a value, then./mychart/values/my.cnfcould then be accessed in templates using{{ .Values.mycnf }}.You now have 3 ways of overriding a value. In the following example we are setting mycnf to "foobar".
Either use the new
--file-set:or use the old school
--setor add a new item in a custom values file:
This feels like a nice solution to me:
Chart Default Values
./values.yaml./values/*Setting Values on Install
helm install --set value=foobar my-charthelm install --values custom.yaml my-charthelm install --file-set value=custom.yaml my-chart@technosophos How do you feel about this?
technosophos commentedon Jan 26, 2017
@syhol I'm not sure I see the difference between the
/valuesproposal and simply using{{ .Files.Get }}I do like the idea of a
--file-set, since it prevents an unexpected injection, but still provides the ability to dump an entire file into a variable.syhol commentedon Jan 27, 2017
The benefit of
/valuesis that the contents end up in.Values. Thats lets us nicely implement default files, while still allowing injection/overriding using existing or new methods (--set --values --file-set).It comes back to my original use case. I want a default key file in the chart, but for staging/prod deploys I want to specify a custom key file instead.
Also the cases I linked to in my last comment look like they want to achieve something similar.
{{ .Files.Get }}would still be a sensible option when you don't want to allow files to be overridden at install time.binoculars commentedon Jul 21, 2017
I found a workaround with bash (v4 required):
E.g. if you have test1.txt, test2.txt in /path/to/files/, the user-supplied values will become:
Happy Helming!
chancez commentedon Aug 1, 2017
Hitting this pain point right now. We're forced to use either an umbrella chart, which hasn't worked well for our current use-case, and bundling our files into our chart is no good because the chart is supposed to be re-usable and not contain any secrets or per-environment configs.
lukasheinrich commentedon Aug 4, 2017
Just adding a +1 for this. We're in the same situation as @chancez in that we want to provide reusable charts where people can add their secrets -- some of which are values that can be set via
--set X.Y.Z=valbut some of which are also files (Kerberos Keytabs, Certificates, etc). To me, the--file-setwould work as it is close to what we're doing now (generating a values yaml file with file contents at specific keys)kevinschumacher commentedon Aug 18, 2017
Like @chancez, an umbrella chart doesn't work great for my use case either.
Seems like there are two main items addressed by @syhol's proposal:
--file-setoption)./values/*directory)I quite the like the proposal and find it pretty clean from a user's perspective (not sure about impl. complexities).
Is there anything suggested here that's against helm's design philosophy? @technosophos any thoughts since you were the last to chime in?
davidkarlsen commentedon Nov 3, 2017
Would love to see this feature!
I’ve developed my generic helm chart for our apps (they basically all extend the same base dockerimage, and place in some config files via configmaps). But .Files read files within the chart - and need to be able to post in arbitrary files via cmd line with helm and get them added to the configmap.
19 remaining items
saplla commentedon Jun 8, 2018
+1 so it's possible to bundle Makefiles into charts so our CD system can download the chart, unpack it and run make to install it, passing appropriate env vars via
--set.feat: Set values from local files
feat: Set values from local files
feat: Set values from local files
feat: Set values from local files
feat: Set values from local files
feat: Set values from local files (#3758)
feat: Set values from local files (helm#3758)
feat: Set values from local files (helm#3758)
feat: Set values from local files (helm#3758)
feat: Set values from local files (helm#3758)
feat: Set values from local files (helm#3758)
abdennour commentedon Jul 17, 2019
--set-file override the default values and does not extend them. I am already searching a solution here: https://stackoverflow.com/questions/57083220/helm-install-set-file-option-does-not-extend-the-default-values
Fix filepath handling on Windows (helm#1754)