I have a Postgres pod which has a mounted volume:
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 100M
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: postgres
name: psql-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100M
The yaml contains the following:
volumeMounts:
- mountPath: /docker-entrypoint-initdb.d/
name: psql-config-map-volume
- mountPath: /var/lib/postgresql/data
name: psql-claim
subPath: postgres
volumes:
- name: psql-config-map-volume
configMap:
name: psql-config-map // contains an init.sql
- name: psql-claim
persistentVolumeClaim:
claimName: psql-claim
It works well, data retain after deployment/pod deletion and redeploy.
The problem appears when I modify the init.sql. It didn't come into effect and got this message at psql pod startup:
PostgreSQL Database directory appears to contain a database; Skipping initialization
The pod itself starts without any error (just with the old init.sql data)
What I have tried:
Deleting the deployment,the pvc and pv. Then redeploy everything. Same result.
I searched the hostpath data but /mnt/data is empty.
What else should I try? How can I force the init.sql to launch? Where the actual old data is stored if not in the hostpath?
edit: I have search for pg files and found this:
/var/lib/docker/overlay2/6ae2../merged/mnt/data/postgres/pg_ident.conf
/var/lib/docker/overlay2/6ae2../diff/mnt/data/postgres/pg_ident.conf
And it still exists after pvc and pv deletion. How can I gracefully reset its data?