I have the following Kubernetes manifest:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: pg-config
data:
POSTGRES_USER: 'myDbUser'
POSTGRES_DB: 'sandbox'
POSTGRES_APP_NAME: 'myApp'
POSTGRES_HOST_AUTH_METHOD: 'scram-sha-256'
POSTGRES_INITDB_ARGS: '--auth-local=scram-sha-256'
---
apiVersion: v1
kind: Secret
metadata:
name: pg-secret
data:
POSTGRES_PASSWORD: somebase64encodedpassword=
---
apiVersion: v1
kind: Pod
metadata:
name: pg-pod
labels:
type: postgres
spec:
containers:
- name: postgres
image: postgres:12.3-alpine
imagePullPolicy: IfNotPresent
ports:
- name: pg-port
containerPort: 5432
envFrom:
- configMapRef:
name: pg-config
- secretRef:
name: pg-secret
volumeMounts:
- name: pg-vol
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-vol
hostPath:
path: /Users/<path-to-app>/application/database/data
restartPolicy: Never
When I apply the manifest I get 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: error: could not access directory "/var/lib/postgresql/data": Permission denied
What is going on here that is causing the permission denied? I am trying to move a docker run command for this to a Kubernetes manifest running locally on minikube v1.11.0
I’ve been looking at this https://github.com/docker-library/docs/tree/master/postgres#arbitrary---user-notes for help but don’t know where to begin in regards to the manifest file.