helm pass all values files from specific folder - kubernetes

I have a folder containing multiple values.yaml files and I would like to pass all the yaml files in that folder as an argument to helm install.
It is possible to use like helm install example . -f values/values1.yaml -f values/values2.yaml
But there are more than 10 files in values folder Is it possible to simply pass a folder as an argument
I already tried helm install example . -f values/* And this does not work.

This is not possible as -f expects a file or URL = specify values in a YAML file or a URL (can specify multiple) and helm does not know a command to use a directory.
Maybe you should reduce your values.yaml files to have a base value file and then one environment specific values file:
helm install example . -f values.yaml -f env/values_dev.yaml

Related

Helm - view generated values from multiple value files

I have multiple values file that Helm will merge together. I'd like to see the resulting values file but I'm not sure how I would do that.
I could run this command and this would result in the generated manifests, but I really just want to see the resulting values file instead.
helm template . -f values.yaml -f values-prod.yaml

File path from within Azure CLI task

I have an Azure CLI task which references a PowerShell script (via build artifact) running az commands. Most of these commands work successfully, but when attempting to execute the following command:
az appconfig kv import --name $resourceName -s file --path appconfig.json --format json
I've noticed that the information was not present against the Azure resource and the log file has "File is not available".
I must be referencing the file incorrectly from the build artifact but if anyone could provide some clarity around this that would be great.
I must be referencing the file incorrectly from the build artifact
You can try to add $(System.ArtifactsDirectory) to the json file path. For example: --path $(System.ArtifactsDirectory)/appconfig.json.
System.ArtifactsDirectory: The directory to which artifacts are downloaded during deployment of a release. Example: C:\agent\_work\r1\a
For details ,please refer to predefined variables .
This can be a little tricky to figure out.
System.ArtifactsDirectory is the default variable that indicates the directory to which artifacts are downloaded during deployment of a release.
However, to use a default variable in your script, you must first replace the . in the default variable names with _. For example, to print the value of artifact variable System.ArtifactsDirectory in a PowerShell script, you would have to use $env:SYSTEM_ARTIFACTSDIRECTORY.
I have a similar setup and do it this way within my PowerShell script:
# Define the path to the file
$appSettingsFile="$env:SYSTEM_ARTIFACTSDIRECTORY\<rest_of_the_path>\appconfig.json"
# Pass it to the Azure CLI command
az appconfig kv import -n $appConfigName -s file --path $appSettingsFile --format json --separator . --yes
It is also helpful to view the current values of all variables to see what they contain before using them.
References:
Default variables - System
Using default variables

How to pass custom yaml file to helm without mentioning its name

I am new to helm chart. As part of the requirement I named my values.yaml to customize.yaml
To tell helm engine that I am using custom yaml file, I used the below command.
helm install mychart -f customize.yaml
but now the question is how should I not pass the name of the yaml (customize.yaml) file as part of the command, so the command should be like this
helm install mychart
and helm should know that it will get the values from customize.yaml
without explicitly mentioning it in the command. Is there a way to do this?
I tried to include it in _helpers.tpl but it didn't work
// ValuesfileName is the default values file name.
ValuesfileName = "values.yaml"
values.yaml have been defined as the default file in helm's source code. So, in your case, you may have to build helm from source with your changes.

Does Kubernetes have the option to have a main manifest file which references all the other manifest files

Currently, I have a number of Kubernetes manifest files which define service's or deployment's. When I do an kubectl apply I need to include -all- the files which have changes and need to be applied.
Is there a way to have a main manifest file which references all the other files so when I do kubectl apply i just have to include the main manifest file and don't have to worry manually adding each file that has changed, etc.
Is this possible?
I did think of making an alias or batch file or bash file that has the apply command and -all- the files listed .. but curious if there's a 'kubernetes' way ....
You may have a directory with manifests and do the following:
kubectl apply -R -f manifests/
In this case kubectl will recursively traverse the directory and apply all manifests that it finds.

Can I have multiple values.yaml files for Helm

Can I have multiple values.yaml files in a Helm chart?
Something like mychart/templates/internalValues.yaml, mychart/templates/customSettings.yaml, etc?
Accessing properties in a values.yaml file can be done by {{ .Values.property1 }}.
How would I reference the properties in these custom values.yaml files?
Yes, it's possible to have multiple values files with Helm. Just use the --values flag (or -f).
Example:
helm install ./path --values ./internalValues.yaml --values ./customSettings.yaml
You can also pass in a single value using --set.
Example:
helm install ./path --set username=ADMIN --set password=${PASSWORD}
From the official documentation:
There are two ways to pass configuration data during install:
--values (or -f): Specify a YAML file with overrides. This can be specified multiple times and the rightmost file will take precedence
--set (and its variants --set-string and --set-file): Specify overrides on the command line.
If both are used, --set values are merged into --values with higher precedence. Overrides specified with --set are persisted in a configmap. Values that have been --set can be viewed for a given release with helm get values . Values that have been --set can be cleared by running helm upgrade with --reset-values specified.
Helm by default will only use the values.yaml file in the root directory of your chart.
You can ask it to load additional values files when you install. For instance, if you have any settings that point to different databases in different environments:
helm install . -f values.production.yaml
You could also get a similar effect by bundling additional settings as a file, and asking Helm to read the bundled file. Helm provides an undocumented fromYaml template function which can parse the file, so in principle you can do something like
{{- $v := $.Files.Get "more-values.yaml" | fromYaml }}
foo: {{ $v.bar }}
Just to update : As per the current official documentation --set & --values will not be merged
To override values in a chart, use either the '--values' flag and pass in a file or use the '--set' flag and pass configuration from the command line, to force a string value use '--set-string'. In case a value is large and therefore you want not to use neither '--values' nor '--set', use '--set-file' to read the single large value from file.
Also :
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the last (right-most) file specified.