I have an azure container service (aks) cluster. It is migrated to version 1.8.1. I am trying to deploy postgres database and use AzureFileVolume
to persist postgres data on.
By default, if I deploy the postgres database without mounting volume, everything is working as excepted, i.e. pod is created and database is initialized.
When I try to mount a volume using the yaml below, I get initdb: could not access directory "/var/lib/postgresql/data": Permission denied.
I tried various hacks as suggested in this long github thread, like: setting security context for the pod or running chown commands in initContainers. The result was the same - permission denied.
Any ideas would be appreciated.
apiVersion: v1
kind: Service
metadata:
labels:
app: myapp
component: test-db
name: test-db
spec:
ports:
- port: 5432
selector:
app: myapp
component: test-db
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-db
spec:
template:
metadata:
labels:
app: myapp
component: test-db
spec:
securityContext:
fsGroup: 999
runAsUser: 999
containers:
- name: test-db
image: postgres:latest
securityContext:
allowPrivilegeEscalation: false
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: myappdb
- name: POSTGRES_USER
value: myappdbuser
- name: POSTGRES_PASSWORD
value: qwerty1234
volumeMounts:
- name: azure
mountPath: /var/lib/postgresql/data
volumes:
- name: azure
azureFile:
secretName: azure-secret
shareName: acishare
readOnly: false