zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.24k stars 969 forks source link

When delete postgres the pvc stay bound to pv , But all data deleted (role+tabels and more ..) #2269

Open heniv96 opened 1 year ago

heniv96 commented 1 year ago

Please, answer some short questions which should help us to understand your problem / question better?

i use operator with postgres 14 and i create pvc with storageclass reclain policy retain.

when i delete the postgres (not the operator) the pv and pvc stay connected , but all the data is deleted. (role,tabels..)

there is option to save the data ?

pvc.yaml:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pgdata-acid-14-0
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
  storageClassName: postgres-data

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pgdata-acid-14-1
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
  storageClassName: postgres-data
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pgdata-acid-14-2
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
  storageClassName: postgres-data

postgres.yaml:

apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
  name: acid-14
spec:
  teamId: "acid"
  spiloFSGroup: 103
  resources:
    limits:
      cpu: 500m
      memory: 500Mi
    requests:
      cpu: 100m
      memory: 100Mi  
  allowedSourceRanges:
    - 0.0.0.0/0
  volume:
    size: 10Gi

  numberOfInstances: 3
  users:
    # database owner
    zalando:
    - superuser
    - createdb

  tls:
    caFile: ca.crt
    caSecretName: pg-tls-ca
    secretName: pg-tls

  postgresql:
    version: "14"

storageclass.yaml:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: postgres-data
provisioner:  cluster.local/nfs-external-provisioner
reclaimPolicy: Retain
parameters:
  archiveOnDelete: "false"
FxKu commented 1 year ago

If you delete the Postgres manifest the Postgres Operator will also delete the PVCs. But in your case they stay around? Why do you delete the Postgres cluster in the first place if you want to keep the data? I think we would use the backup location to bootstrap a new cluster with the old data if we need it and not keep volumes around.