Manage Multiple Environments With Helmfile
Learn how to prepare configuration for multiple environments in a single helmfile.
Introduce two environments
In real projects, we usually need to maintain more than one environment. Apart from a production environment (where a company’s revenue is generated), we can have a development, test, pre-production, and many more. It’s a good practice to keep them as similar as they can be. In the end, we don’t want to be surprised when installing software on production and it turns out that it’s not the same as the one used for development.
However, that’s not always the case. In some situations, we need to have a different configuration for each environment. It may be related to security reasons—perhaps with production, we don’t want to expose any unprotected REST endpoints, which are very handy for development or debugging but don’t have any particular use in regular tasks.
To solve it with Helm we would probably have an environment-specific configuration encapsulated in the values.yaml
file. For each Helm release, we could have a generic, all-purpose values.yaml
file that would be applied to every environment. Along with that, a second environment-specific values.yaml
file may be added to the helm upgrade
command. (Remember: We can provide as many values files as we want).
And how can we approach the same problem with Helmfile? It’s very simple. We can of course have separate Helmfiles for each environment, but luckily for us, there is another approach. We can add the environments
property to the Helmfile definition and specify different configurations for each one of them.
Here is a simple code snippet from the Helmfile where we declare configurations:
environments:default:production: