Reputation: 657
I'm writing a script that executes multiple helm install commands based on a config file.
In this config file the user needs to be able to specify additional arguments e.g. --set userPw="password"
.
Some of these arguments require retrieval of variables from somewhere.
In powershell, I can store this in a variable, and use this variable in the helm install --set argument as follows:
$mySecret = az keyvault secret show --name MYSECRET--vault-name MYVAULT| ConvertFrom-Json).value
helm install mydeployment repo/mychart -n my-namespace --set azureSecret=$mySecret
I can't do this dynamically however... Different deployments ofcourse need different variables. I want to use the config file rather than variables, since I don't want the users to edit the script that runs these commands.
Is something like this possible for helm install?:
helm install mydeployment repo/mychart -n my-namespace --set azureSecret=(az keyvault secret show --name MYSECRET--vault-name MYVAULT| ConvertFrom-Json).value)
In that case users would be able to put commands like this in the config file. My syntax could be off, I tried some variations but it doesn't seem to work.
This script is only used by our team to easily deploy some stuff, so security is not an issue.
I think it isn't allowed according to: https://github.com/helm/helm/issues/5145
Just want to make sure.
Upvotes: 0
Views: 2097
Reputation: 83
this is possible using simple bash command like EX. you want to get the password value from abc.txt file from your machine location you can simple do like this
helm install . --name abc --set userPw=userPw,[^"]*' /opt/abc.txt
use your bash command in inside `` to grep/sed to get the values from some file or get the values using command.
Upvotes: 0
Reputation: 159171
Helm in fact can't directly launch subcommands. Helm also disables the Sprig functions that can query the shell environment. The only input to templates is the values object built from the chart's values.yaml
file and -f
and --set
options.
In a Unix-like environment you can use $(az keyvault ...)
command-substitution syntax in your helm install
command. (I know there are a couple of ways to run the GNU Bash shell on Windows and one of these might work.) The command you show is involved enough that writing a short script to run it would be beneficial, and if you have it in a script, your two-line Powershell script will work as well.
In a continuous-integration environment another approach that can work well is to write out a YAML values file, and then pass that via the helm install -f
option. All valid JSON should be valid YAML, so you can set up e.g. a Jenkins pipeline to compute some values, make a Groovy map object, dump it as JSON to a file, and then use that as an input values file.
Upvotes: 2