How hamedsafikhani/takhfifan-payment-dr works
This repository documents a PostgreSQL payment-database disaster-recovery exercise: deploy a master and streaming replica, establish a healthy baseline, simulate dirty data during live traffic, recover to a point before the incident, and selectively merge the recovered state while preserving later valid transactions. A separate monitoring branch exposes database metrics and alerts. The graph follows the README and file tree; source excerpts were unavailable, so links whose wiring is not documented are omitted.
Main entry points: 03-master-statefulset.yaml Postgres master · 05-replica-statefulset.yaml Postgres replica · kind-config.yaml kind cluster · 03-exporters.yaml DB exporters
Components 18
Database topology
- kind cluster
kind/kind-config.yaml - Postgres master
k8s/03-master-statefulset.yaml - Write service
k8s/04-master-services.yaml - Postgres replica
k8s/05-replica-statefulset.yaml - Read service
k8s/06-replica-services.yaml - Schema initialization
k8s/02-configmap-init-sql.yaml - Payment schema
sql/01-schema.sql
Recovery workflow
- WAL archive
k8s/03-master-statefulset.yaml - PITR instance
k8s/07-recovery-pod.yaml - Selective merge
sql/04-recovery-merge.sql
Payment workload
- Baseline data
sql/02-seed-data.sql - Traffic generator
scripts/traffic-generator.sh - Dirty-data incident
sql/03-incident.sql
Monitoring
- DB exporters
k8s/monitoring/03-exporters.yaml - Prometheus
k8s/monitoring/06-prometheus.yaml - Alert rules
k8s/monitoring/05-prometheus-config.yaml - Grafana dashboard
k8s/monitoring/09-grafana.yaml
Other components
- DBA / operator
Connections 24
- DBA / operator → kind cluster: provisions
- DBA / operator → Postgres master: operates
- kind cluster → Postgres master: hosts
- kind cluster → Postgres replica: hosts
- Schema initialization → Postgres master: initializes
- Payment schema → Schema initialization: defines schema
- Postgres master → Write service: serves writes
- Postgres replica → Read service: serves reads
- Postgres master → Postgres replica: streams WAL
- Postgres master → WAL archive: archives WAL
- DBA / operator → Baseline data: loads baseline
- Baseline data → Postgres master: seeds rows
- Traffic generator → Write service: sends traffic
- DBA / operator → Dirty-data incident: executes
- Dirty-data incident → Postgres master: damages data
- DBA / operator → PITR instance: starts PITR
- WAL archive → PITR instance: supplies WAL
- DBA / operator → Selective merge: executes merge
- Selective merge → Postgres master: restores selected rows
- Postgres master → DB exporters: exposes metrics
- Postgres replica → DB exporters: exposes metrics
- DB exporters → Prometheus: scrapes metrics
- Alert rules → Prometheus: configures alerts
- Prometheus → Grafana dashboard: feeds dashboards