Closed
Description
Trying to setup a kubernetes cluster and have created a persistent volume thus:
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv-volume
labels:
type: local
app: postgres
spec:
storageClassName: manual
capacity:
storage: 2Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/data/postgres"
where,
/data is a mounted filesystem on minikube startup, say $HOME/data.
A claim binds to the above pv:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pv-claim
labels:
app: postgres
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 2Gi
The postgres pod is created as follows:
apiVersion: v1
kind: Pod
metadata:
name: postgres
labels:
app: postgres
tier: backend
spec:
hostname: postgres
containers:
- name: postgres
image: postgres:9.5
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-config
volumeMounts:
- mountPath: "/var/lib/postgresql/data"
name: postgresdb
volumes:
- name: postgresdb
persistentVolumeClaim:
claimName: postgres-pv-claim
However, the pod/container is never created. It complains:
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: could not access directory "/var/lib/postgresql/data": Permission denied
I have tried setting the permissions of the mounted directory to be owned by postgres:postgres but still getting the same error.
Thanks!