<p>I want to save users accounts and other settings in a volume for a pgadmin4 k8s instance, I did that:</p>
<pre><code>    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: pgadmin
      namespace: pgadmin
    spec:
      selector:
       matchLabels:
        app: pgadmin
      replicas: 1
      template:
        metadata:
          labels:
            app: pgadmin
        spec:
          containers:
            - name: pgadmin4
              image: dpage/pgadmin4
              env:
               - name: PGADMIN_DEFAULT_EMAIL
                 value: &quot;admin@example.com&quot;
               - name: PGADMIN_DEFAULT_PASSWORD
                 value: &quot;mysecpwd&quot;
               - name: PGADMIN_PORT
                 value: &quot;80&quot;
              ports:
                - containerPort: 80
                  name: pgadminport
              volumeMounts:
                - mountPath: /
                  name: pgadmin-storage

          volumes:
               - name: pgadmin-storage
                 persistentVolumeClaim:
                   claimName: pgadmin-pv-claim
    ---
        kind: PersistentVolume
        apiVersion: v1
        metadata:
          name: pgadmin-pv-volume
          namespace: pgadmin
          labels:
            type: local
            app: pgadmin
        spec:
          storageClassName: manual
          capacity:
            storage: 5Gi
          accessModes:
            - ReadWriteMany
          hostPath:
            path: &quot;/mnt/data&quot;
    ---
        kind: PersistentVolumeClaim
        apiVersion: v1
        metadata:
          name: pgadmin-pv-claim
          namespace: pgadmin
          labels:
            app: pgadmin
        spec:
          storageClassName: manual
          accessModes:
            - ReadWriteMany
          resources:
            requests:
              storage: 5Gi
</code></pre>
<p>The problem is when I restart the pod the created users disappears even if the pv is bounded to the pod, I'm not sure about this section:</p>
<pre><code>              volumeMounts:
                - mountPath: /
                  name: pgadmin-storage
</code></pre>
<p>I think I have to specify the directory where the user's information and settings are saved, I tried the default directory <code>/pgadmin4</code> but the pod crashes.</p>

<p>based on @Wytrzymały answer, I checked the deployment created with helm, and I found that the correct <code>mountPath</code> is <code>/var/lib/pgadmin</code>, the section should be like so:</p>
<pre><code>      ...
      volumeMounts:
        - mountPath: /var/lib/pgadmin
          name: pgadmin-storage
      ...
</code></pre>
<p>another thing is that I had to change owner of that directory so the application can write to it, I used <code>InitContainers</code> for that (pgadmin uid = 5050):</p>
<pre><code>...
spec:
  initContainers:
    - name: volume-mount-hack
    image: busybox
    command: [&quot;sh&quot;, &quot;-c&quot;, &quot;chown -R 5050:5050 /var/lib/pgadmin&quot;]
    volumeMounts:
      - name: pgadmin-storage
        mountPath: /var/lib/pgadmin
....
</code></pre>
<p>hope this can help somebody</p>
