简体   繁体   中英

Postgres on K8s: mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied while Initializing PostgreSQL database

I am using zammad helm to launch zammad on my Kube.netes cluster (bare metal). It uses bitnami postgreSql chart to provision Postgres database.

the problem is that whenever i install helm with --set volumePermissions.enabled=true:

helm upgrade --install zammad zammad/zammad --namespace zammad --set persistence.storageClass="manual" --set volumePermissions.enabled=true

PostgreSql still gives error:

sana@SANA3:~/sampleApp$ kubectl logs pod/zammad-postgresql-0
postgresql 11:12:15.65
postgresql 11:12:15.66 Welcome to the Bitnami postgresql container
postgresql 11:12:15.66 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
postgresql 11:12:15.66 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
postgresql 11:12:15.66
postgresql 11:12:15.69 INFO  ==> ** Starting PostgreSQL setup **
postgresql 11:12:15.72 INFO  ==> Validating settings in POSTGRESQL_* env vars..
postgresql 11:12:15.73 INFO  ==> Loading custom pre-init scripts...
postgresql 11:12:15.74 INFO  ==> Initializing PostgreSQL database...
mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied

This is my storage-class:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"manual-postgre"},"provisioner":"kubernetes.io/no-provisioner","volumeBindingMode":"Immediate"}
  creationTimestamp: "2023-01-25T07:05:38Z"
  name: manual-postgre
  resourceVersion: "10359744"
  uid: ad6bb681-18eb-4f80-9995-2d00273e9b08
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Delete
volumeBindingMode: Immediate
                     

This is my PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"hostpath-postgre2"},"spec":{"accessModes":["ReadWriteOnce"],"capacity":{"storage":"8Gi"},"claimRef":{"apiVersion":"v1","kind":"PersistentVolumeClaim","name":"data-zammad-postgresql-0","namespace":"zammad"},"hostPath":{"path":"/var/postgre2","type":"DirectoryOrCreate"},"persistentVolumeReclaimPolicy":"Retain","storageClassName":"manual-postgre"}}
    pv.kubernetes.io/bound-by-controller: "yes"
  labels:
    type: local
  name: hostpath-postgre2
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 8Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: data-zammad-postgresql-0
    namespace: zammad
  hostPath:
    path: /var/postgre2
    type: DirectoryOrCreate
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual-postgre
  volumeMode: Filesystem

This is my PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"zammad","app.kubernetes.io/name":"postgresql"},"name":"data-zammad-postgresql-0","namespace":"zammad"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"8Gi"}},"storageClassName":"manual-postgre","volumeMode":"Filesystem","volumeName":"hostpath-postgre2"}}
    pv.kubernetes.io/bind-completed: "yes"
  labels:
    app.kubernetes.io/instance: zammad
    app.kubernetes.io/name: postgresql
  name: data-zammad-postgresql-0
  namespace: zammad
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 8Gi
  storageClassName: manual-postgre
  volumeMode: Filesystem
  volumeName: hostpath-postgre2

Can you tell what am i missing here for permission.

The same install command for helm worked alright on a microK8s kube.netes with NO permission issue. Why is the error coming on bare metal kube.netes

The bitnami postgresql helm chart requires volume mount path to be /bitnami/postgresql by default, changing PV volume path from /var/postgre2 to /bitnami/postgresql solved issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM