<p>I would like to create a helm chart for PostgreSQL with PVC (persistent volume claim).</p>
<p>I've looked at trying katacoda <a href="https://www.katacoda.com/courses/kubernetes/helm-package-manager" rel="noreferrer">https://www.katacoda.com/courses/kubernetes/helm-package-manager</a>
Create Postgres helm chart with pvc.</p>
<p>How might I do this?</p>

rrrr
<p>As we can read from <a href="https://hub.helm.sh/charts/bitnami/postgresql" rel="noreferrer">PostgreSQL</a> helm charts docs it can be used with following <a href="https://github.com/bitnami/charts/tree/master/bitnami/postgresql/#parameters" rel="noreferrer">parameters</a>:</p>

<pre><code>+----------------------------+-----------------------------------------------------------------+---------------+
|         Parameter          |                           Description                           |    Default    |
+----------------------------+-----------------------------------------------------------------+---------------+
| persistence.enabled        | Enable data persistence                                         | true          |
| persistence.existingClaim  | Use a existing PVC which must be created manually before bound  | nil           |
| persistence.storageClass   | Specify the storageClass used to provision the volume           | nil           |
| persistence.mountPath      | Path to mount data volume at                                    | nil           |
| persistence.accessMode     | Access mode of data volume                                      | ReadWriteOnce |
| persistence.size           | Size of data volume                                             | 8Gi           |
| persistence.annotations    | Persistent Volume Claim annotations                             | {}            |
+----------------------------+-----------------------------------------------------------------+---------------+
</code></pre>

<blockquote>
  <h2>Persistence</h2>
  
  <p>The data is persisted by default using PVC templates in the PostgreSQL statefulset. You can disable the persistence setting the  <code>persistence.enabled</code>  parameter to  <code>false</code>. A default  <code>StorageClass</code>  is needed in the Kubernetes cluster to dynamically provision the volumes. Specify another StorageClass in the  <code>persistence.storageClass</code>  or set  <code>persistence.existingClaim</code>  if you have already existing persistent volumes to use.</p>
</blockquote>

<p>This means you just need to create your own <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="noreferrer">Persistent Volume</a> which can for example look like this:</p>

<p><em>pv.yaml</em></p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
</code></pre>

<p><em>pvc.yaml</em></p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 8Gi
</code></pre>

<p>Once those are deployed and bounded you can install the PostgreSQL chart:</p>

<p><code>helm install my-release bitnami/postgresql --set persistence.existingClaim=task-pv-claim</code></p>
