This article explores deploying DocumentDB, a MongoDB-compatible database built on PostgreSQL, with high availability on Kubernetes using a dedicated operator. It details the architecture for local HA, leveraging CloudNativePG for WAL replication and failover, and demonstrates automatic primary failover to ensure minimal downtime for applications.
Read original on DZone MicroservicesThe article focuses on achieving local high availability (HA) for DocumentDB within a single Kubernetes cluster. DocumentDB, being a MongoDB-compatible database built on PostgreSQL, relies on the underlying PostgreSQL capabilities for its HA mechanisms. The DocumentDB Kubernetes Operator extends the Kubernetes platform with custom resources to manage these database clusters declaratively, automating deployment, scaling, upgrades, and HA scenarios.
The DocumentDB Kubernetes Operator offers multiple layers of high availability, addressing various failure domains:
The local HA architecture for DocumentDB on Kubernetes integrates several key components:
Automatic Failover Mechanism
When the primary DocumentDB instance fails, CNPG automatically detects this, promotes the most advanced replica to become the new primary, and updates the pod labels. The Kubernetes external Gateway service then automatically updates its routing to point to the new primary, ensuring the external IP remains stable and minimizing application disruption without requiring manual DNS changes.