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=$mySecretI 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.
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.