Video in progress
Run PostgreSQL and Kafka inside Kubernetes with an operator, or use a managed service: how do you decide?
The main question is whether the team has experience running these systems 24/7, backing them up, upgrading them and recovering them in an incident. If not, a managed service is almost always cheaper. Running inside Kubernetes makes sense when control, cost or on-prem requirements are strong.
📖 Answer
Operators (CloudNativePG, Strimzi) are quite mature and easy to install. But installing is the smallest part of the work.
The real cost of a stateful system inside Kubernetes:
- storage: the PVC's performance, zone binding (a pod cannot move to another zone), growing the disk size;
- upgrades: every upgrade of the Kubernetes nodes also moves the DB pods. If the PDB and the operator are not set up correctly, that is a series of failovers;
- backup and restore: there is a backup, but when was it last restored? Has point-in-time recovery been practiced?
- incidents: a problem with the Kafka controller at night. Is there anyone on the team who understands it?
- resource contention: on shared nodes the DB is affected by a neighboring app, and you often need a separate node pool.
The cost of managed (RDS, Cloud SQL, MSK, Confluent Cloud):
- the direct bill is bigger, especially for Kafka traffic;
- configuration and version choice are limited;
- vendor lock-in and network latency (it is outside the cluster).
In the decision I look at:
- DBA/SRE experience on the team, and on-call;
- RPO/RTO requirements, and whether we can prove them with our own solution;
- regulation: whether data must stay in the country (Uzbekistan has a personal data localization requirement, which often limits the managed options);
- scale: at small volumes managed is cheap, and at very large volumes running our own can make economic sense.
A mix by environment is normal too: dev and preview environments inside Kubernetes with an operator (cheap, quick to create), and in prod a managed service or a cluster run by a dedicated team.
Sign up to mark studied questions and save your progress.