I have the following kubernetes yaml file:
1 apiVersion: apps/v1
1 kind: Deployment
2 metadata:
3 name: postgres-deployment
4 spec:
5 replicas: 1
6 selector:
7 matchLabels:
8 component: postgres
9 template:
10 metadata:
11 labels:
12 component: postgres
13 spec:
14 securityContext:
15 runAsUser: 999
16 runAsGroup: 999
17 fsGroup: 999
18 volumes:
19 - name: postgres-storage
20 persistentVolumeClaim:
21 claimName: postgres-persistent-volume-claim
22 containers:
23 - name: postgres
24 image: prikshet/postgres
25 ports:
26 - containerPort: 5432
27 volumeMounts:
28 - name: postgres-storage
29 mountPath: /var/lib/postgresql/data
30 subPath: postgres
31 imagePullPolicy: Always
But the pod is giving the following logs:
2021-08-11 06:06:15.749 GMT [8] LOG: skipping missing configuration file "/var/lib/postgresql/data/postgresql.auto.conf"
2021-08-11 06:06:15.750 UTC [8] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2021-08-11 06:06:15.750 UTC [8] HINT: The server must be started by the user that owns the data directory.
Whereas clearly I have the fsGroup, runAsUser and runAsGroup specified. What might be causing this error?