I am starting to get my arms around using Kubernetes and Helm. Most of it makes perfect sense to me. I am missing one thing though and maybe someone can answer me. Why is there a separate Chart.yaml and values.yaml file? it seems to me that it would make better sense on a helm install command to have one file with a standard name. Asking for some DevOps wisdom.
Chart.yaml contains metadata about the chart itself: its name, the chart version, a description, and similar details. In Helm 3 it can contain dependencies as well.
values.yaml contains configuration settings for the chart. This typically includes things like the image repository to pull from, where you want data to be stored, and how to make the service accessible.
When you install the chart, you can use helm install -f to supply an additional YAML file of configuration options that override things in value.yaml, or helm install --set to set a single specific value. You can't override things in the Chart.yaml.
In the template code, items in Chart.yaml and values.yaml are available in the top-level data items .Chart and .Values, respectively.
Related
Right now my application repos have directories that look like this:
myapp
code/
myappChartConfig/
myappChart/
dev.yaml
prod.yaml
The chart is in myappChart/ and my dev/prod settings are outside it in dev/prod yaml files. On deploy if it's dev or prod, the right config is supplied with -f.
I want instead to include my dev/prod YAML files inside the chart itself. So when I push the chart to a repo it includes the configs and when I pull it down I get the chart and its configs.
Does Helm support this? This is not the helmignore use case. I want to include these files in the chart but I don't want helm to process them as though they are manifests- they are values files (but not the default values.yaml file, env specific ones).
What I want to avoid is something wonky like naming the files dev.yaml.deploy and then have scripts pull down the chart and move and rename those files before running helm upgrade. It would be nice to refer to them with -f and have them be inside the chart's folder when it's pulled down.
You can split it into 2 charts.
Chart named prod includes a values.yaml file containing the configuration values of prod.
Chart named dev includes a values.yaml file containing the configuration values of dev.
Hope it's useful for you!
I need to install a helm chart with a key/value that is not present in one of the templates and I prefer not to edit the already existing templates.
In particular, I need to change resources.limits.cpu and resources.limits.memory in k8s-job-template.yaml but resources is not even mentioned in that file.
Is there a solution for this?
The only customizations it's possible to make for a Helm chart are those the chart author has written in; you can't make arbitrary additional changes to the YAML files.
(Kustomize allows merges of arbitrary YAML content and is built into recent kubectl, but it doesn't have some of the lifecycle or advanced templating features of Helm.)
For future reference, I found a solution to this.
Simply download the chart using the following command:
helm fetch <chart> --untar --destination /local/path/to/chart
Go to the folder /local/path/to/chart/<chartname> and make the desired changes.
After this, simply install the helm chart based on the locally edited chart:
helm install /local/path/to/chart/<chartname>
Hi everyone,
I have deployed a Kubernetes cluster based on kubeadm and for the purpose of performing HorizontalPodAutoscaling based on the Custom Metrics, I have deployed prometheus-adpater through Helm.
Now, i want to edit the configuration for prometheus-adpater and because i am new to Helm, i don't know how to do this. So could you guid me how to edit the deployed helm charts?
I guess helm upgrade is that are you looking for.
This command upgrades a release to a specified version of a chart and/or updates chart values.
So if you have deployed prometheus-adapter, you can use command helm fetch
Download a chart from a repository and (optionally) unpack it in local directory
You will have all yamls, you can edit them and upgrade your current deployed chart via helm upgrade
I found an example, which should explain it to you more precisely.
You're trying to customize an installed chart. Please use this guide Customizing the Chart Before Installing.
The key parts:
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 name=value: Specify overrides on the command line
There are a couple more ways to customize a Helm Chart values:
You may create a file with defined config and then helm install my-app [chart] -f /path/to/myconfig.yaml
As an example for a config file, please refer, for example, to redis one.
The second one is to check for the files the helm repo add or helm repo update create. You may check with helm env the variable HELM_REPOSITORY_CACHE that shows where those files are.
Untar the chart and look for the values config file or even go to the Kubernetes manifests /templates for a more in-depth customization. Then, install the chart.
I'm new to Helm and I haven't quite fully grasped the concepts yet. What I'm currently trying to do is to create a custom chart that basically just sets specific values for another chart that's available in the default stable repository. Pretty much what I want to do is have this:
helm install \
-f my-custom-values.yaml \
stable/target-chart \
--name=my-release
changed into
helm install my-apps/my-release
With my-release using the same values in my-custom-values.yaml. It's essentially bundling the pre-existent chart into a new one with my custom values.
Is there a way to do this? I think I might be able to clone the source chart, but I don't feel like that's a practical thing to do.
What is the issue with the first variation? If you have a custom values.yaml that you can pass to helm why do you need to remove it from the command line?
But if you are ready to play around a bit... :)
One way of doing this would be creating your own chart, that will be mainly empty but consist of a requirements.yaml that refers to stable/target-chart.
requirements.yaml (just beside Chart.yaml)
dependencies:
- name: stable/target-chart
version: 1.0.0.0.0.0
alias: somealiasforvaluesyaml
In your values.yaml you then overwrite the values of that sub-chart:
somealiasforvaluesyaml:
keyfromthattargetchart: newvalue
subkeyfromthattargetchart:
enabled: true
setting: "value"
The alias you give in the requirements.yaml is the section in your values.yaml from your chart.
Before installing you need to tell helm to update these requirements:
helm repo update
helm dependency update
and then just helm install this (virtual?) chart. This chart does not contain any resources to it would not be called a package in linux package managers - but they also use transitional packages or packages that just are a collection of others (like the build-essential)
Considering you already have the values.yaml to overwrite the ones in the target-chart this is all a bit much? Since the cust-values .yaml to pass to install with -f just needs to contain the customization as it will ammend the values.yaml from the target-chart your first command in the question looks like the correct way to go.
With helm inspect [CHART] I can view the content of chart.yaml and values.yaml of a chart. Is there a way to also view the template files of a chart? Preferably through a Helm command.
On a sidenote: this seems like a pretty important feature to me. I would always want to know what the chart exactly does before installing it. Or is this not what helm inspect was intended for? Might the recommended way be to simply check GitHub for details how the chart works?
helm install yourchart --dry-run --debug
This will print to stdout all the rendered templates in the chart (and won't install the chart)
you can use helm fetch if you want to download the whole chart:
download a chart from a repository and (optionally) unpack it in local directory
(from the doc)
helm inspect returns the default values.yaml for the chart:
This command inspects a chart and displays information. It takes a chart reference ('stable/drupal'), a full path to a directory or packaged chart, or a URL.
Inspect prints the contents of the Chart.yaml file and the values.yaml file.
(from the doc)
If you want to check the templates for given chart you can use helm template [chartname] command.
The docs describe it as :
Render chart templates locally and display the output.
Any values that would normally be looked up or retrieved in-cluster will be faked locally. Additionally, none of the server-side testing of chart validity (e.g. whether an API is supported) is done.