简体   繁体   English

带有Helm的PostgreSQL中的意外持久存储

[英]Unintended persistent storage in PostgreSQL with Helm

Short version: PostgreSQL deployed via Helm is persisting data between deployments unintentionally. 简短版本:通过Helm部署的PostgreSQL意外地在部署之间保留数据。 How do I make sure data is cleared? 如何确保清除了数据?

Long version: I'm currently deploying PostgreSQL via Helm this way, using it for a local development database for an application I'm building: 长版:我目前正在以这种方式通过Helm部署PostgreSQL,并将其用于我正在构建的应用程序的本地开发数据库中:

helm install stable/postgresql -n testpg \
    --set global.postgresql.postgresqlDatabase=testpg \
    --set global.postgresql.postgresqlUsername=testpg \
    --set global.postgresql.postgresqlPassword=testpg \
    --set global.postgresql.servicePort=5432 \
    --set service.type=LoadBalancer

When I'm done (or if I mess up the database so bad and need to clear it), I uninstall it: 完成后(或者如果我将数据库弄得很糟并且需要清除它),请卸载它:

helm del --purge testpg

(which confirms removal and kubectl get all confirms works) (这确认删除,并且kubectl get all confirms作品)

However, when I spin the database up again, I'm surprised to see that the data and schema are still there when it has spun up. 但是,当我再次启动数据库时,我很惊讶地看到旋转起来后数据和架构仍然存在。

How is the data persisting and how do I make sure I have a clean database each time? 数据如何持久保存,如何确保每次都有干净的数据库?

Other details: 其他详情:

  • My Kubernetes Cluster is running in Docker Desktop v2.0.0.3 我的Kubernetes集群正在Docker Desktop v2.0.0.3中运行

Your cluster may have a default volume provisioner configured. 您的群集可能配置了默认的卷配置程序。

https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/#defaulting-behavior https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/#defaulting-behavior

So even if you have no storage class configured a volume will be assigned. 因此,即使您没有配置存储类别,也将分配一个卷。

You need to set helm value persistence.enabled to false. 您需要将头盔值persistence.enabled设置为false。

The value is true by default: 默认情况下,该值为true:

https://github.com/helm/charts/blob/master/stable/postgresql/values.yaml https://github.com/helm/charts/blob/master/stable/postgresql/values.yaml

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

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