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.