<p>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,</p>

<ol>
<li>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.</li>
</ol>

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

<p>Your chart should declare <code>postgresql</code> as a <a href="https://helm.sh/docs/topics/charts/#chart-dependencies" rel="noreferrer">dependency</a>, in Helm 3 in its <code>Chart.yaml</code> file.  (In Helm 2 there was <a href="https://v2.helm.sh/docs/developing_charts/#chart-dependencies" rel="noreferrer">a separate <code>requirements.yaml</code> file</a>.)  You will need to run <code>helm dep up</code> (<code>helm dependency update</code>) before deploying your chart, but then when you run <code>helm install</code> it will install both your application and its database dependency.</p>

<p>So your <code>Chart.yaml</code> can look roughly like</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v2
name: app
...
dependencies:
  - name: postgresql
    version: '^8'
    repository: @stable
</code></pre>

<p>(In Helm 3 you also need to <a href="https://github.com/helm/charts#how-do-i-enable-the-stable-repository-for-helm-3" rel="noreferrer"><code>helm repo add</code> the stable Helm charts repository</a>.)</p>

<p>You can configure the database per environment in the same way you configure the rest of your application.  Database settings would be <a href="https://helm.sh/docs/topics/charts/#scope-dependencies-and-values" rel="noreferrer">nested under the subchart's name</a>; at the command line you might <code>--set postgresql.postgresqlPassword=...</code>, and in a YAML file you'd put database settings under a <code>postgresql:</code> key.</p>

<p>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.</p>
