Back to Glossary
Workloads

StatefulSet

A controller for stateful applications that provides stable Pod identities, ordered deployment, and per-Pod PersistentVolumeClaims.

What is StatefulSet?

StatefulSets are the Kubernetes workload controller for applications that require persistent identity, ordered operations, or stable storage — databases (PostgreSQL, MySQL, Cassandra), message brokers (Kafka, RabbitMQ), and distributed consensus systems (etcd, ZooKeeper) are typical examples. Unlike Deployments, each Pod in a StatefulSet gets a deterministic name (e.g., mysql-0, mysql-1, mysql-2) that persists across rescheduling, along with a stable DNS hostname and its own PersistentVolumeClaim.

StatefulSets deploy Pods in strict order (mysql-0 before mysql-1) and terminate them in reverse order, ensuring that a primary database node is always the last to shut down. Scaling up follows the same ordered pattern. The volumeClaimTemplates section of a StatefulSet spec creates one PVC per Pod replica using a named template — these PVCs are not deleted when the StatefulSet is scaled down or deleted, by design, to protect data.

This data-protection behavior means StatefulSet PVCs are a frequent source of orphaned storage cost. When a StatefulSet is deleted or scaled down, its PVCs remain bound to their backing cloud volumes and continue to incur charges until manually deleted.

Example

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres
  namespace: databases
spec:
  serviceName: postgres-headless
  replicas: 3
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:15
        resources:
          requests:
            cpu: "1"
            memory: "2Gi"
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: ["ReadWriteOnce"]
      storageClassName: ssd
      resources:
        requests:
          storage: 100Gi

Cost & Waste Implications

StatefulSet PVCs survive StatefulSet deletion and must be manually cleaned up. A 3-replica StatefulSet using 100Gi SSD PVCs on GKE costs ~$51/month in storage alone — and those PVCs persist and keep billing even after the StatefulSet is gone. Teams running dozens of short-lived StatefulSet-based dev environments routinely accumulate thousands of dollars in forgotten PVC charges.

KorPro— Kubernetes Cost Optimization

How KorPro Helps

KorPro detects PVCs created by deleted or scaled-to-zero StatefulSets, estimates their monthly cloud cost, and flags them as high-confidence orphan candidates for audit-first cleanup.

Scan Your Cluster Free

Stop Wasting Money on Orphaned Kubernetes Resources

KorPro connects to your clusters across GCP, AWS, and Azure — no agents, no installation — and surfaces every orphaned resource with its monthly cost estimate.