Kubernetes Cluster Simulator: Live HA, Failover & Fencing
- Docs
- Production & Operations
- Kubernetes Simulator
simulator · kubernetes + postgresql 19
Break pods. Kill Postgres. Verify zero loss.
A live discrete-event model of bunqueue’s multi-broker Kubernetes runtime. Scale stateless replicas, inject SIGTERM drains, SIGKILL crashes, network partitions, node power-offs, and database restarts while watching /ready probes, lease handoffs, and stale ACK fencing in real time.
Scenarios:
Live cluster topology
Pods & Nodes
| Pod | Node | Phase | /ready | Leases | RSS | Inject fault |
|---|---|---|---|---|---|---|
| bunqueue-a1 | node-1 | Running | 200 | 0 | 173 / 512M | |
| bunqueue-b2 | node-2 | Running | 200 | 0 | 174 / 512M | |
| bunqueue-c3 | node-3 | Running | 200 | 0 | 175 / 512M | |
| bunqueue-d4 | node-1 | Running | 200 | 0 | 176 / 512M |
Conservation & Invariant Proof
Waiting0
Active leases0
Completed0
Lost / Dupes0 / 0
Fenced ACKs0
Handoffs0
p99 pickup4 ms
Throughput
Cluster Events
- 00:00[endpoints]Service/bunqueue :6789 routing across 4 Ready endpoints
- 00:00[kube]Deployment/bunqueue Ready (4/4) · PostgreSQL 19.0 Schema v22
How the simulation maps to real bunqueue v2.9.25
Section titled “How the simulation maps to real bunqueue v2.9.25”| Behavior | What you see here | Real bunqueue + Kubernetes runtime |
|---|---|---|
| Pod identity | Each recreated pod gets a fresh <pod>:<pid>:<hex> broker ID | Omit static BUNQUEUE_BROKER_ID so restarted containers skip the 30 s fencing lockout |
Graceful drain (SIGTERM) | /ready flips to 503, Service/bunqueue removes the endpoint, owned leases hand off to siblings | beginDrain() stops lease reassignment onto draining pods; measured 4 s drain |
Pod crash (SIGKILL) | Pod dies with active leases; PostgreSQL DB clock expires leases and RecoverySweeper reclaims them | Surviving broker increments generation token and re-queues without manual intervention |
| Split-brain partition | Partitioned pod finishes locally and sends a late ACK; PostgreSQL rejects it and increments Fenced ACKs | Lease generation fencing guarantees two workers never both complete the same job |
| PostgreSQL restart | All pods flip /ready 503 while postgres-0 restarts, then auto-heal back to N/N Ready | connectionTimeout: 5s + bounded retry loop recovers in 5-6 s |
| PodDisruptionBudget | Voluntary SIGTERM drains stop when ready <= minAvailable | PodDisruptionBudget (minAvailable: 2) protects cluster capacity during node drains |
Schema upgrade (Recreate) | Drains old pods, holds pg_advisory_lock(bunqueue:schema), boots new revision cleanly | Prevents mixed binary versions against one PostgreSQL namespace during schema bumps |
Ready to deploy this exact topology? Follow the Step-by-Step Kubernetes Guide or explore the single-node Queue Engine Simulator.