reactive-tech / kubegres

Kubegres is a Kubernetes operator allowing to deploy one or many clusters of PostgreSql instances and manage databases replication, failover and backup.
https://www.kubegres.io
Apache License 2.0
1.31k stars 74 forks source link

PVC are not deleted #20

Open timvol opened 3 years ago

timvol commented 3 years ago

I'm not sure if it's a bug or feature, but other operators like the ECK are deleting the PVC's when I delete the stateful set. So it would be great if Kubegres can support deleting the PVC's, too.

alex-arica commented 3 years ago

Thank you for your message and your suggestion.

By default Kubegres keeps the default behaviour for StatefulSets where Kubernetes does not delete PVC on StatefulSet deletion.

However, I can add an option in the Kubegres YAML so that you could enable deletion of PVC for your cluster of Postgres. I am adding this feature in the backlog.

Note: the implication of this new feature would be, if you enable the deletion of PVC, then in the case of a failover happening, the PVC of the failed StatefulSet would be deleted. By default, we keep PVC so that some teams can investigate the contents of the PVC in order to find the reasons of a failover.

amobdlp commented 2 years ago

For our business case it would be also very helpful if the PVC could be deleted. " PVC so that some teams can investigate the contents of the PVC in order to find the reasons of a failover", the reason of the failover is, in our case, at 99,99 % that the node on which is running the StatefulSets is put under maintenance or we intentionally kill the pod during High Availability. Waiting for this feature, we have set a manual job to delete the PVC after a fail-over, but it looks not very nice inside our fully automated recovery design. Hope you can find time to add this feature and thank you for the great job!

alex-arica commented 2 years ago

Thank you! I am planning to work on this feature at some stage. It is the next feature in our backlog.

We usually work on Kubegres for 1 week consecutively and at the end of each month.

Note that if it is urgent and someone from the community decides to implement it and send me a PR, I will be happy to review it asap.

margeaux-gendron commented 2 years ago

Hi, wanted to add a +1 to this request. I am using kubegres to handle autoscaling events (our nodes have a set lifetime maximum), so I am left with a bunch of old PVCs I don't need.

I also wanted to point out kubernetes 1.23 has introduced an option for statefulsets to automatically clean up PVCs when they are deleted. Which might make implementing this easier.

https://github.com/kubernetes/kubernetes/pull/99728 https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.23.md

Thanks!

alex-arica commented 2 years ago

@margeaux-gendron thank you for sharing this.

I prioritised this feature and it is going to be available as part of the next version of Kubegres.

alex-arica commented 2 years ago

We are very busy currently. If a developer is willing to implement this change, I am available to review their PR.

We decided to let the community to be more involved in the project and therefore until end of summer 2022, I will only make a code change when it is required.

With this approach, we are hoping there would be additional developers involved in this project and more PRs submitted.