Alamgir Qazi
Alamgir Qazi

Reputation: 793

Persistent Volume for Postgres Database in Kubernetes Cluster

I have created a Persistant Disk Claim for my Postgres Database.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: pgdata
  name: pgdata
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}

Once I delete the cluster, the volume got deleted too. what's the best practice here? Should I save in some other Persistent Disk like GCEPersistentDisk? I dont want to lose the volume even If cluster is deleted and what are the best strategies for deployment?

Upvotes: 1

Views: 1761

Answers (1)

Nicola Ben
Nicola Ben

Reputation: 11377

In the PersistenVolume manifest you can set the reclaiming policy (Retain or Delete, there was a third option now deprecated - Recycle):

persistentVolumeReclaimPolicy: Retain

Reference: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#claims-as-volumes

Upvotes: 2

Related Questions