Skip to content
_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 DE
Let's talk

Kubernetes — Stateful Workloads in Practice

16. 09. 2025 Updated: 24. 03. 2026 1 min read intermediate

Cloud Intermediate

Kubernetes — Stateful Workloads in Practice

KubernetesStatefulSetDatabasesStorage 6 min read

Running stateful applications on Kubernetes. Databases, message brokers, storage classes and data persistence.

Stateful vs Stateless

  • Stable hostnamemysql-0, mysql-1
  • Ordered deployment — 0 → 1 → 2
  • Stable storage — PVC per pod
  • Headless Service — DNS per pod

PostgreSQL StatefulSet

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgresql
spec:
  serviceName: postgresql
  replicas: 3
  template:
    spec:
      containers:
        - name: postgres
          image: postgres:16-alpine
          ports:
            - containerPort: 5432
          env:
            - name: PGDATA
              value: /var/lib/postgresql/data/pgdata
          volumeMounts:
            - name: data
              mountPath: /var/lib/postgresql/data
          resources:
            requests:
              cpu: 500m
              memory: 1Gi
          livenessProbe:
            exec:
              command: ["pg_isready", "-U", "postgres"]
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: [ReadWriteOnce]
        storageClassName: fast-ssd
        resources:
          requests:
            storage: 100Gi
  • CloudNativePG — PostgreSQL (CNCF sandbox)
  • Percona Operators — MySQL, MongoDB, PostgreSQL
  • Strimzi — Apache Kafka
  • Redis Operator — Spotahome

Operators handle: failover, backup, restore, upgrades, connection pooling, monitoring.

Storage Best Practices

  • reclaimPolicy: Retain for data
  • SSD StorageClass for databases
  • CSI VolumeSnapshot for point-in-time recovery
  • Do not use ReadWriteMany for databases
  • Test disaster recovery scenarios

Summary

Stateful workloads on K8s are production-ready. Prefer operators and always test failover and restore.

Need Help with Implementation?

Our team has experience designing and implementing modern architectures. We’re happy to help.

Free Consultation

Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.