How does values.yaml for Helm work?

Saumya Bakshi
2 min readMay 3, 2021

--

If you’ve worked on a Kubernetes cluster, then there is a high chance that you’ve come across Helm as a package manager .The companies I’ve worked for are heavily dependent on Helm to deploy applications to various environments. It makes the process of describing deployment details easy and flexible with it’s templating mechanism. It also has a means of passing values to the templates via a built-in object called Values.

Last week, we decided to add node selectors in some of our helm charts to promote stability in our clusters. We had a values.yaml, a values-staging.yaml and so on for different environments. We added the node selector changes only to the values.yaml filr. But while deploying to a different environment using ‘-f values-staging.yaml ’, we noticed that our node selector changes were getting reflected in this environment as well. We were dumbstruck for a while, then decided to consult the official documentation . That’s when we learnt that the values.yaml file is considered a default by Helm. It then uses the files provided by us via -f or variables provided via — set to override those values in values.yaml. Although it seems obvious now, it is something that many of us don't realize while using Helm.

So how did we find a solution for this ? There are two ways and both are pretty simple.

  1. The first is to rename the values.yaml file to anything other than that. This way the helm chart won’t have a default set of values and everything will only be taken by what we provide.
  2. Second would be to make sure that the values are correctly overridden in every other values yaml file. So in our case, we could have added an if condition template for our nodeselector and set the value to true or false accordingly in the different values yaml files.

This was something that I had missed out on while using Helm since such a long time. Better late than never. Thanks for reading!

--

--