<p>I'm trying to deploy an application that uses PostgreSQL as a database to my minikube. I'm using helm as a package manager, and add have added PostgreSQL dependency to my requirements.yaml. Now the question is, how do I set postgres user, db and password for that deployment? Here's my <code>templates/applicaion.yaml</code></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: {{ template "sgm.fullname" . }}-service
spec:
  type: NodePort
  selector:
    app: {{ template "sgm.fullname" . }}
  ports:
  - port: 80
    targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "sgm.fullname" . }}-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: {{ template "sgm.fullname" . }}
  template:
    metadata:
      labels:
        app: {{ template "sgm.fullname" . }}
    spec:
      containers:
      - name: sgm
        image: mainserver/sgm
        env:
        - name: POSTGRES_HOST
          value: {{ template "postgres.fullname" . }}.default.svc.cluster.local
</code></pre>

<p>I've tried adding a configmap as it is stated in the postgres helm chart github Readme, but seems like I'm doing something wrong</p>

vcmkrtchyan
<p>This is <a href="https://helm.sh/docs/developing_charts/#scope-dependencies-and-values" rel="nofollow noreferrer">lightly discussed in the Helm documentation</a>: your chart's <code>values.yaml</code> file contains configuration blocks for the charts it includes.  The GitHub page for the <a href="https://github.com/helm/charts/tree/master/stable/postgresql" rel="nofollow noreferrer">Helm stable/postgresql chart</a> lists out all of the options.</p>

<p>Either in your chart's <code>values.yaml</code> file, or in a separate YAML file you pass to the <code>helm install -f</code> option, you can set parameters like</p>

<pre><code>postgresql:
  postgresqlDatabase: stackoverflow
  postgresqlPassword: enterImageDescriptionHere
</code></pre>

<p>Note that the chart doesn't create a non-admin user (unlike its sibling MySQL chart).  If you're okay with the "normal" database user having admin-level privileges (like creating and deleting databases) then you can set <code>postgresqlUser</code> here too.</p>

<p>In your own chart you can reference these values like any other</p>

<pre><code>- name: PGUSER
  value: {{ .Values.postgresql.postgresqlUser }}
</code></pre>
