_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

StatefulSets in Production — PostgreSQL and Elasticsearch on Kubernetes

06. 11. 2019 1 min read CORE SYSTEMSdata
StatefulSets in Production — PostgreSQL and Elasticsearch on Kubernetes

In 2017, we started with StatefulSets in beta. Today we run PostgreSQL clusters and Elasticsearch on Kubernetes in production. Two years of experience in one article.

PostgreSQL on Kubernetes

We use the Patroni operator for PostgreSQL HA. Three-node cluster: primary + 2 replicas. Automatic failover, streaming replication, point-in-time recovery from WAL archives in S3.

What works: automatic failover, backup scheduling, resource isolation. What’s challenging: storage performance tuning, major version upgrades (still a manual process), connection pooling (PgBouncer as a sidecar).

Elasticsearch on Kubernetes

Elastic Cloud on Kubernetes (ECK) operator. 3 master nodes, 3 data nodes, 2 coordinating nodes. Automatic scaling, rolling upgrades, snapshot backups.

The ECK operator is excellent — you define the desired state, the operator takes care of the rest. Upgrading Elasticsearch from 6.x to 7.x was done via rolling update with no downtime.

Lessons Learned

  • Storage class matters: SSD (gp2/gp3) for databases, always
  • Anti-affinity: replicas on different nodes/AZs
  • Resource requests = limits for guaranteed QoS
  • Test backups regularly — restore drill every month
  • Monitoring: databases need specific metrics (replication lag, connections, locks)

When NOT on Kubernetes

Extremely performance-sensitive workloads (bare metal latency is still lower). Huge databases (TB+) with complex sharding. Legacy databases without a Kubernetes operator.

Stateful Workloads on Kubernetes Are Production-Ready

With a good operator, proper storage, and disciplined operations, it works. But respect the limits — not every database belongs in Kubernetes.

statefulsetspostgresqlelasticsearchkubernetes
Share:

CORE SYSTEMS

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.

Need help with implementation?

Our experts can help with design, implementation, and operations. From architecture to production.

Contact us