cloudnative-pg / charts

CloudNativePG Helm Charts
Apache License 2.0
144 stars 63 forks source link

postgres uses wrong directory for pgwal #329

Closed unbelauscht closed 2 weeks ago

unbelauscht commented 3 weeks ago

CNPG mounts the pgwal directory at the wrong location.

postgres expects the directory at /var/lib/postgresql/data/pgdata/pg_wal, but it's mounted at /var/lib/postgresql/wal.

yaml:

---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: authentik-pg
  namespace: authentik
spec:
  instances: 1
  storage:
    storageClass: longhorn
    size: 20Gi
  walStorage:
    storageClass: longhorn
    size: 20Gi
  bootstrap:
    initdb:
      database: authentik
      owner: authentik
      secret:
        name: authentik-postgres-credentials

log:

{"level":"info","ts":"2024-07-06T20:30:11Z","logger":"setup","msg":"Starting CloudNativePG Instance Manager","logging_pod":"authentik-pg-1","version":"1.23.2","build":{"Version":"1.23.2","Commit":"4bef8412","Date":"2024-06-12"}}
2024-07-06T22:30:11.102158730+02:00 Error: lstat /var/lib/postgresql/data/pgdata/pg_wal: no such file or directory

kubectl describe -n authentik pod authentik-pg-1

Name:             authentik-pg-1
Namespace:        authentik
Priority:         0
Service Account:  authentik-pg
Node:             node-02/192.168.40.102
Start Time:       Sat, 06 Jul 2024 22:26:56 +0200
Labels:           cnpg.io/cluster=authentik-pg
                  cnpg.io/instanceName=authentik-pg-1
                  cnpg.io/instanceRole=primary
                  cnpg.io/podRole=instance
                  role=primary
Annotations:      cnpg.io/nodeSerial: 1
                  cnpg.io/operatorVersion: 1.23.2
                  cnpg.io/podEnvHash: 8c8c8c7f8
                  cnpg.io/podSpec:
                    {"volumes":[{"name":"pgdata","persistentVolumeClaim":{"claimName":"authentik-pg-1"}},{"name":"scratch-data","emptyDir":{}},{"name":"shm","...
Status:           Running
SeccompProfile:   RuntimeDefault
IP:               10.42.1.139
IPs:
  IP:           10.42.1.139
Controlled By:  Cluster/authentik-pg
Init Containers:
  bootstrap-controller:
    Container ID:    containerd://d0afd8c2478ade56afcc9e4b519b2a8779d0c737f31da60676aa7b6f568414da
    Image:           ghcr.io/cloudnative-pg/cloudnative-pg:1.23.2
    Image ID:        ghcr.io/cloudnative-pg/cloudnative-pg@sha256:f1f3c20f3637be5a8d1d702a55b6d25719e6b4ca63d1b56473e7ecec83157fde
    Port:            <none>
    Host Port:       <none>
    SeccompProfile:  RuntimeDefault
    Command:
      /manager
      bootstrap
      /controller/manager
      --log-level=info
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Sat, 06 Jul 2024 22:27:05 +0200
      Finished:     Sat, 06 Jul 2024 22:27:06 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /controller from scratch-data (rw)
      /dev/shm from shm (rw)
      /etc/app-secret from app-secret (rw)
      /run from scratch-data (rw)
      /var/lib/postgresql/data from pgdata (rw)
      /var/lib/postgresql/wal from pg-wal (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-kfsgn (ro)
Containers:
  postgres:
    Container ID:    containerd://086c0740fb4632b2023ec0600316608531181381fd6735abcbadf8bb289ed40e
    Image:           ghcr.io/cloudnative-pg/postgresql:16.0
    Image ID:        ghcr.io/cloudnative-pg/postgresql@sha256:5baf99e0fb30a051d8e108eeecb558af65a7119e068a280641873a2b98e35457
    Ports:           5432/TCP, 9187/TCP, 8000/TCP
    Host Ports:      0/TCP, 0/TCP, 0/TCP
    SeccompProfile:  RuntimeDefault
    Command:
      /controller/manager
      instance
      run
      --log-level=info
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Sat, 06 Jul 2024 22:28:00 +0200
      Finished:     Sat, 06 Jul 2024 22:28:00 +0200
    Ready:          False
    Restart Count:  3
    Liveness:       http-get http://:8000/healthz delay=0s timeout=5s period=10s #success=1 #failure=3
    Readiness:      http-get http://:8000/readyz delay=0s timeout=5s period=10s #success=1 #failure=3
    Startup:        http-get http://:8000/healthz delay=0s timeout=5s period=10s #success=1 #failure=360
    Environment:
      PGDATA:        /var/lib/postgresql/data/pgdata
      POD_NAME:      authentik-pg-1
      NAMESPACE:     authentik
      CLUSTER_NAME:  authentik-pg
      PGPORT:        5432
      PGHOST:        /controller/run
    Mounts:
      /controller from scratch-data (rw)
      /dev/shm from shm (rw)
      /etc/app-secret from app-secret (rw)
      /run from scratch-data (rw)
      /var/lib/postgresql/data from pgdata (rw)
      /var/lib/postgresql/wal from pg-wal (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-kfsgn (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  pgdata:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  authentik-pg-1
    ReadOnly:   false
  scratch-data:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
  shm:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     Memory
    SizeLimit:  <unset>
  app-secret:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  authentik-postgres-credentials
    Optional:    false
  pg-wal:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  authentik-pg-1-wal
    ReadOnly:   false
  kube-api-access-kfsgn:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason     Age                     From               Message
  ----     ------     ----                    ----               -------
  Normal   Scheduled  3m59s                   default-scheduler  Successfully assigned authentik/authentik-pg-1 to node-02
  Normal   Pulled     3m51s                   kubelet            Container image "ghcr.io/cloudnative-pg/cloudnative-pg:1.23.2" already present on machine
  Normal   Created    3m51s                   kubelet            Created container bootstrap-controller
  Normal   Started    3m51s                   kubelet            Started container bootstrap-controller
  Normal   Pulled     2m57s (x4 over 3m50s)   kubelet            Container image "ghcr.io/cloudnative-pg/postgresql:16.0" already present on machine
  Normal   Created    2m57s (x4 over 3m50s)   kubelet            Created container postgres
  Normal   Started    2m56s (x4 over 3m50s)   kubelet            Started container postgres
  Warning  BackOff    2m51s (x10 over 3m48s)  kubelet            Back-off restarting failed container postgres in pod authentik-pg-1_authentik(ed15c0cc-0bf9-4207-a4bb-0569c11a80f3)

Operator image is ghcr.io/cloudnative-pg/cloudnative-pg:1.23.2