1

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 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

6 Comments

@appreciate for your useful response that will be open my horizon.. But it might be my fault ı forgot to specify, there is already stable chart in our private registry which I think to install postgresql independently..In this scenario should I use dependency again?
You can point at a different repository: without really changing this workflow.
Should I need helm registry plugin? Because internally another unit has a postgresql image in private registry and needs to pull it from there.
This is all built-in functionality in Helm; if your local helm command can reach the chart registry then all you should need to do is helm repo add it.
understood. I think we need our own repository because.. I can able to reach chart registry but that chart is not suitable for helm 3.. Is there any easy way to convert it t Helm 3?
|
0

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

4 Comments

Thanks for your respose but this is not I want.. my question is how can I install the postreSQL and pass the values to different environment.
Should I install independently? so what I need to do to make a communication between my microservice and postreSQL?
Let's say, one instance of PSQL is created. Provide service name, username, password in the microservice. In microservice you will give will give something like, jdbc:postgresql://psql-instance-1-service.namespace:5432/myusersdb. Again you install helm chart with different values.yaml to create another instance of Postgres
What is the best way to do this in microservices? Using configmap or any other solution to ensure following best practices? I could not find any examples for Helm 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.