Skip to content

change db into a StatefulSet - #89

Closed
SimoneLazzaris wants to merge 1 commit into
supabase-community:mainfrom
SimoneLazzaris:stateful_db
Closed

change db into a StatefulSet#89
SimoneLazzaris wants to merge 1 commit into
supabase-community:mainfrom
SimoneLazzaris:stateful_db

Conversation

@SimoneLazzaris

Copy link
Copy Markdown

Changed the DB component into a stateful set. This avoid having two instances of the DB running on the same data, which can happen with a deployment (i.e., during an update/reconfiguration).
Also, added a shutdown command to properly shut down the database, to prevent data corruption.

What kind of change does this PR introduce?

The DB deployment is changed into a StatefulSet. Since there can only be one pod mounting and using the data volume at a time, the correct semantic is to use a StatefulSet.

What is the current behavior?

Using a deployment allows kubernetes to do rolling updates, which mean that a new pod is started on the same Persistent Volume while the old one is shutting down.

That can cause data corruption - which I've personally observed - when upgrading the helm chart.

What is the new behavior?

In the statefulset semantic, at most only one pod can be scheduled to run, so you don't have this issue.
I've also add a lifecycle command so that when the pod is shut down, postgres is commanded to shut down as well, so that it can close in a controlled fashion.

Changed the DB component into a stateful set. This avoid having two instances of
the DB running *on the same data*, which can happen with a deployment (i.e., during
an update/reconfiguration).
Also, added a shutdown command to properly shut down the database, to prevent
data corruption.
@shivani446

Copy link
Copy Markdown

Any updates on this? @SimoneLazzaris

@SimoneLazzaris

Copy link
Copy Markdown
Author

Unfortunately, no news from the supabase development team. I'd like to have this patch applied

@Max-Levitskiy

Copy link
Copy Markdown

yep, it should be merged. I did the same with my fork. :)

@Dathix

Dathix commented May 19, 2025

Copy link
Copy Markdown

I agree.

kastakhov added a commit to wiseinfotec/helm-charts that referenced this pull request Jul 27, 2025
Merging some pull requests from
[original](https://github.com/supabase-community/supabase-kubernetes)
repository.

- supabase-community/supabase-kubernetes#62
- supabase-community/supabase-kubernetes#89
- supabase-community/supabase-kubernetes#91
- supabase-community/supabase-kubernetes#94
- supabase-community/supabase-kubernetes#95
- supabase-community/supabase-kubernetes#96
- supabase-community/supabase-kubernetes#101
- supabase-community/supabase-kubernetes#106
- supabase-community/supabase-kubernetes#107
- supabase-community/supabase-kubernetes#113

---------

Co-authored-by: Varantha <sam@kiessler.co.uk>
Co-authored-by: naki3004 <45875285+naki3004@users.noreply.github.com>
Co-authored-by: jingyu <francismajere@gmail.com>
Co-authored-by: Chris Alfano <chris@jarv.us>
Co-authored-by: Simone Lazzaris <slazzaris@gmail.com>
Co-authored-by: Mikey032 <26899585+Mikey032@users.noreply.github.com>
Co-authored-by: Upik Saleh <upxsal@gmail.com>
Co-authored-by: Scott Beardsley <scott@beards.ly>
@luizfelmach

Copy link
Copy Markdown
Contributor

Hey @SimoneLazzaris, thanks a lot for the contribution 🙏

Apologies that this important fix wasn’t merged earlier. This has now been addressed in PR #131, which also brings the key updates aligned with the 2025 Supabase setup.

Going forward, we’ll make a conscious effort to keep this repository as up to date as possible, using the official docker-compose.yml as the reference:
https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml

Cc @aantti

@aantti

aantti commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

As mentioned, hopefully this was finally resolved. Closing :)

@aantti aantti closed this Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants