How to Use Multiple Value Files in a Helm Chart for Microservices?

0
11
Asked By CuriousCactus42 On

I'm working on a project with 10 microservices, and currently, I only have a single values file that contains configurations for all of them. I'd like to switch to using separate values files for each microservice. This way, it'll be easier for me to manage changes specific to each service without having to sift through a giant file. The catch is that I need these to be installed under the same release name. I'm encountering an issue where when I run `helm upgrade`, the existing pods are being deleted, and only the last pod corresponding to the latest values file gets installed. I stumbled upon using helmfile, which streamlines the install/upgrade process, but I still need to write a script to merge all the values files into one, and that means extra work every time I add a new service. Is there a way to automate this, so I only need to specify the path of the new values file and it handles the installation without manual merging?

3 Answers

Answered By CodeNinja77 On

You can actually pass multiple values files directly when running Helm install by using the `-f` flag several times. It also looks like you’ll want to utilize the `--reuse-values` flag during the upgrade to keep the existing values you've applied. Just remember to add both the `-f` flag for any overrides along with `--reuse-values` when you upgrade.

DevDoodle -

I tried this but the pods still got deleted. Each of my value files has different Docker images.

TechyTina -

Okay, thanks! I’ll give that a shot and see how it goes.

Answered By MicroserviceMaven On

One approach is to create dedicated values files for each microservice like `microservice1.yaml`, `microservice2.yaml`, etc. You can deploy each one by running a command specifically for that service: `helm install microservice1 microservice1 -f microservice1.yaml`. This keeps them separate for easier management. If you want something a bit more complex, you could consider making a base template for microservices and utilizing it as a subchart.

CuriousCactus42 -

I did that, but when I upgrade the values for another microservice in the same namespace, it still gets deleted.

Answered By YAMLWizard On

You might want to set up your helm charts to point to multiple value files directly in your helm configuration. Something like this would be helpful:
```yaml
helm:
valueFiles:
- values/service1.yaml
- values/service2.yaml
- ...
``` This way, it keeps them organized and you can reference them easily.

CodeWarrior32 -

Can you clarify what you mean by that?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.