Two Kubernetes clusters for disaster recovery shouldn't cost twice as much
Most multi-cluster HA setups run active/active, which means paying for full workloads on both clusters around the clock. For our production workloads, I wanted automatic disaster recovery without the standby cluster burning money every day. So I built an active/passive multi-cluster setup with Karmada ๐ ๐น ๐ข๐ป๐ฒ ๐ฐ๐ผ๐ป๐๐ฟ๐ผ๐น ๐ฝ๐น๐ฎ๐ป๐ฒ, ๐๐๐ผ ๐๐๐ฏ๐ฒ๐ฟ๐ป๐ฒ๐๐ฒ๐ ๐ฐ๐น๐๐๐๐ฒ๐ฟ๐ Karmadaโฆ
Most multi-cluster high availability setups operate on an active/active basis, requiring full workloads on both clusters 24/7. To avoid the unnecessary costs of maintaining a standby cluster, a user designed an active/passive multi-cluster configuration using Karmada. The system utilizes K3s to manage both clusters, with deployments, services, ingress, configmaps, and secrets propagated through a single PropagationPolicy.
Workloads are automatically routed to the primary cluster using ClusterAffinities, staying on standby until the primary becomes unavailable. In the event of a failure, Automatic failover uses a ClusterTaintPolicy to move workloads to the backup cluster without manual intervention. However, once the primary cluster recovers, Karmada does not automatically shift the workloads back.
A CronJob-based fail-back mechanism was developed to address this issue, waiting for the primary cluster to remain healthy for 15 minutes before clearing scheduler affinity, triggering a reschedule, and moving workloads back to the primary cluster. Cloudflare Load Balancer was added for traffic management, implementing primary and backup pools, HTTPS/healthz monitoring, and automatic failover, eliminating the need for an additional HAProxy layer.
This approach provides disaster recovery without the continuous expenses of running full production capacity on both clusters. A step-by-step guide on the installation, cluster join, failover hardening, fail-back script, and load balancer options is available on GitHub.
Written by urgent.news from Dev.to's reporting โ not their text. Machine-written โ may contain errors; check the original before relying on it.