简体   繁体   English

Kubernetes集群中Postgres数据库的持久卷

[英]Persistent Volume for Postgres Database in Kubernetes Cluster

I have created a Persistant Disk Claim for my Postgres Database. 我已经为我的Postgres数据库创建了一个永久磁盘声明。

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? 我应该保存在其他持久性磁盘(如GCEPersistentDisk)中吗? I dont want to lose the volume even If cluster is deleted and what are the best strategies for deployment? 即使删除群集,我也不想丢失卷,最佳部署策略是什么?

In the PersistenVolume manifest you can set the reclaiming policy (Retain or Delete, there was a third option now deprecated - Recycle): 在PersistenVolume清单中,您可以设置回收策略(保留或删除,现在不建议使用第三个选项-回收):

persistentVolumeReclaimPolicy: Retain

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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