1
votes

I have a few microservices and one of them needs to use postreSQL. I configure this microservice using Helm 3.I have two different values.yaml per environments such as values.stage.yaml and values.prod.yaml.So my confusion is,

  1. Should I independentyl install the PostreSQL? What I mean, in my scr code I have helm chart call helm/app. Should I create one more chart for PostreSQL? How can I configure the PostreSQL per environments.

2.In future, if one more microservice would like to use the same PostreSQL, what should I do to provide this feature.

2

2 Answers

5
votes

Your chart should declare postgresql as a dependency, in Helm 3 in its Chart.yaml file. (In Helm 2 there was a separate requirements.yaml file.) You will need to run helm dep up (helm dependency update) before deploying your chart, but then when you run helm install it will install both your application and its database dependency.

So your Chart.yaml can look roughly like

apiVersion: v2
name: app
...
dependencies:
  - name: postgresql
    version: '^8'
    repository: @stable

(In Helm 3 you also need to helm repo add the stable Helm charts repository.)

You can configure the database per environment in the same way you configure the rest of your application. Database settings would be nested under the subchart's name; at the command line you might --set postgresql.postgresqlPassword=..., and in a YAML file you'd put database settings under a postgresql: key.

If you have a second service that needs PostgreSQL, it should declare a dependency in the same way and install its own independent copy of the database. With database installation isolated inside containers this isn't considered particularly heavy-weight. If your two services need to communicate, they should do it via a network (often HTTP) connection and not by sharing a database.

0
votes

By default, Helm picks values.yaml of root directory of the chart.

To install same Helm Chart with different values, you can do something like,

helm install . -f values.stage.yaml