StatefulSets for Vector Databases and Persistence
What You'll Learn
You'll learn why vector databases and other stateful AI components need special Kubernetes handling and how StatefulSets provide stable identities and persistent storage.
The Statefulness Problem
Most AI model serving containers are stateless—spin one up, kill it, replace it, no problem. But vector databases (like Weaviate, Milvus, or Qdrant) store embeddings that must survive restarts and maintain consistent network identities. If you use regular Deployments for these, you risk data loss and broken cluster coordination.
Analogy: Think of stateless containers as hotel guests (any room works), but stateful services are like homeowners—they need the same house with their stuff inside every time they return.
What StatefulSets Provide
Unlike Deployments, StatefulSets guarantee:
- Stable network identity: Each pod gets a predictable DNS name like
vectordb-0,vectordb-1, etc. - Ordered deployment: Pods start sequentially, ensuring proper initialization
- Persistent Volume Claims (PVCs): Each pod gets its own dedicated storage that persists across restarts
When to Use StatefulSets
Use StatefulSets for:
- Vector databases storing embeddings
- Distributed training checkpoints
- Model registries requiring persistent storage
- Any clustered system needing peer discovery (Kafka, Redis, Elasticsearch)
The Architecture
Each StatefulSet pod maintains a 1:1 binding with a PersistentVolumeClaim. When vectordb-1 restarts, it automatically reattaches to its original storage volume, preserving all indexed embeddings and metadata.
Key Takeaway: StatefulSets solve the persistence and identity challenges for stateful AI infrastructure components by providing stable network names and dedicated persistent storage that survives pod restarts—essential for vector databases in production RAG systems.