I have started minikube with --mount --mount-string “/path/to/local/directory:/data” and kvm2 driver. Followed every tutorial blog to a T to get persistent volume created for postgres to work but keep getting the following error:
The files belonging to this database system will be owned by user “postgres”.
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
initdb: directory "/var/lib/postgresql/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/postgresql/data" or run initdb
with an argument other than "/var/lib/postgresql/data".
The pv and pvc are created successfully and bound. Here’s the yaml section for postgres pod:
Is this a postgres issue? minikube issue? or both? Can’t figure out and spent more than couple of weeks trying to. None of the resources on the internet that say it should work have helped (so far).
I understand it is a postgres issue, but not an expert.
My guess is that initdb expects an empty dir for to create it from scratch, if you already have data and want to use it you probably don’t want to call initdb? I don’t know, just a guess
Which command are you running that generates that output? My uninformed bet would be that you may want to run another command.
Thanks for your reply. I am making sure the directory is empty before I start deploying postgres pods. So that is not the issue as far as I have understood.
I am running the usual command to create the pod:
kubectl create -f postgres.yml
The yaml file is the one I posted earlier. There is already a PersistentVolume and a PersistentVolumeClaim created.
The moment I don’t provide a PersistentVolume, the pod comes up happily. It just doesn’t agree with a PersistentVolume created from a local directory.
I have other pods (for nginx) and they seem to be okay with PersistentVolume created from local directory.
Sorry, this might not be the smartest question, but just to be sure. The local directory that you mount is empty too? If you connect to the pod and run ls -a is empty too?
HI
I am also facing mount issue with local kubernetes with docker-desktop.
I get below logs
2020-08-17 15:44:13.159 UTC [51] FATAL: data directory “/var/lib/postgresql/data/dbfiles” has wrong ownership
2020-08-17 15:44:13.159 UTC [51] HINT: The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory “/var/lib/postgresql/data/dbfiles”
Any one has fix for this issue.