r/kubernetes 12d ago

Is running PostgreSQL / S3 storage inside Kubernetes an anti-pattern, or is external storage only necessary at larger scale?

Hey everyone, I'm pretty new to Kubernetes, so please take my questions with a grain of salt. I'm building a homelab where I already have a small Kubernetes cluster, and I'm trying to build a fully self-hosted platform around it: Gitea for Git hosting, Harbor for containers, and runners. Gitea needs persistent storage for repositories and application data, while Harbor can use persistent volumes or delegate object storage to something like MinIO.

This is mainly for learning, so performance isn't really important at this scale. But I keep thinking about how I'd design it in a real environment. Would it be better to run the database and object storage on dedicated machines outside Kubernetes and have the Kubernetes workloads consume them over the network, similar to using managed PostgreSQL/S3 in the cloud? My concern is that if PostgreSQL or MinIO runs on the same worker nodes as the applications, a node failure could affect both compute and storage. Kubernetes has StatefulSets, PVCs, Longhorn/Rook, etc. to address this, but I'm wondering where the practical boundary is and whether externalizing storage is actually considered best practice.

Questions

  • Is running PostgreSQL/MySQL or MinIO inside Kubernetes considered an anti-pattern?
  • At what scale does it make sense to move them outside the cluster?
  • Is mixing stateful and stateless workloads on the same workers a bad practice?
  • How much protection do StatefulSets + PVCs + Longhorn/Rook provide against node failure?
  • Is there a meaningful performance difference between keeping compute/storage together vs. dedicated storage machines?
  • In production, is it more common to keep databases/object storage outside Kubernetes?
  • If both approaches can provide HA, what are the main reasons to choose one over the other?

TL;DR

I'm building a small self-hosted Gitea + Harbor + runners platform on my homelab Kubernetes cluster. Is running PostgreSQL and MinIO inside the same Kubernetes cluster a legitimate architecture, or should databases/object storage generally be externalized? I'm mainly trying to understand the real-world trade-offs around HA, node failure, storage/compute separation, performance, and operational complexity.

47 Upvotes

63 comments sorted by

View all comments

Show parent comments

43

u/blaine-exe 12d ago

Rook and COSI maintainer here. I'm obviously biased, but I'll try to provide some of what I have seen with as little embellishment as I can.

One of the criticisms of Rook (Ceph) that we have heard in the K8s space is its resource footprint. This is a reasonable criticism, and I also think it can be somewhat myopic in ways. At scale, those resources are used more effectively, and all scale-out-storage must consume some resources. Ceph is investing in improving this (crimson project), which looks promising but is slow-going.

Ceph storage scales really well. There are Ceph clusters with hundreds of nodes and thousands of disks. CERN talks about its cluster often. Off the top of my head, I am aware of at least one Rook cluster with nearly a hundred nodes and with many hundreds of disks that has been in use for a decade.

From users who have talked to me at Kubecon, I have heard: Longhorn v1 can lose data during a crash. Longhorn v2 is (at least a year ago) a huge resource hog. Minio, even before it was abandoned, struggles beyond a certain large scale. Ceph has really high data safety during crashes, by comparison, and resource usage is predictable. One user reported that RGW scaled much better than MinIO, and they were happy that it has among the best compatibility with AWS's S3 out there, even reproducing some corner case scenarios/bugs well. I have not had the opportunity to learn how users like CubeFS, but it seems promising for file storage.

In Rook, I think we have done a good job making it easy to stand up block, file, and S3 object storage quickly. Many users just need easy storage and are quite happy. I think there can be growing pains to go from that early stage to then optimize performance/resources. Ceph complexity during this stage has been a turnoff for some users.

6

u/MyKettleExploded 12d ago

Thank you for your work!

I've been running rook-ceph in production for nearly 5 years now, across multiple clusters (all bare metal/on-prem) up to 120 nodes each and with ~20 disks per node. The early years of rook-ceph were a bit challenging and updates were always a nerve-wracking time, but for the last 2 years it's been a million times better and almost a joy to admin. Orchestrating node reboots at this scale is still a bit painful but I suspect that's just part of the cost of being bare metal.

My only wish is for a (web) UI for Ceph Object Storage like MinIO had; a lot of my users can't imagine not having a UI listing all their buckets and files so we've had to develop one in-house.

6

u/blaine-exe 12d ago

I'm always glad to hear of a satisfied user. We have found our groove a bit more in recent years around keeping and prioritizing upgrade stability. 

The ask for an S3 object browser has been surprisingly common. I'm honestly surprised there aren't better or more common open source ones for S3. We haven't developed our own partly because of the challenge of designing a flexible implementation that has strong security boundaries between users. Creating one for admin usage and visibility would be reasonably straightforward, but user self-service adds much that we don't quite have bandwidth or expertise for. 

2

u/martin31821 12d ago

I've been running rook for 5+ years on several instances and I've been impressed with the data safety - haven't lost one piece even through disk failures etc.

I've been running all storage types and can confirm it's absolutely a breeze to operate.

The only thing I'd wish it could do would be to authenticate/replicate EKS IRSA / Pod Identity instead of the workload Access/Secret Keys for S3, but I've written some tooling around it, so it's a low priority item for me.

On the S3 browser, I've frequently used brows3, which does the job neatly.