You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Introduction

As part of the HA (High Availability) investigation, the decision was made to focus on the use of certain tools in testing and implementation.

As a database HA solution for Postgres, the Patroni project was chosen. Patroni's solution involves a primary-replica structure for replication. Writes and reads are made to the primary and the data is streamed asynchronously to the replicas. The primary is referred to as the leader in the documentation and this database instance becomes leader by way of a leader election. The elected leader holds a lock. All other instances see this and assume a role as a secondary. If the leader node dies, a new election is done and a new leader is selected. This process is extremely quick.

For backup and restore a tool called Velero was chosen. Velero is a widely used and comprehensive tool for backup of Kubernetes resources, including persistent volumes. The CLI provided by Velero is easy to use and adopts a good amount of the syntax used by kubectl.

The remainder of this document will show a deployment of a 5 pod Patroni cluster inside a Kubernetes environment. The database cluster will then be backed-up, destroyed and then restored - in that order.

Notes

  • This demonstration assumes that you have a running Kubernetes cluster and a helm repo (The name used in this case for the repo is "local").
  • A tool called "minio" is used to simulate connection to AWS. In a real world situation, minio would not be needed because a Kubernetes cluster would be backed by cloud provider storage.

Running minio

Firstly, we will install minio on the machine you are using with Docker.

docker run --name minio -p 9000:9000 -v data:/data minio/minio server /data

This creates a docker container based on the minio image and exposes the service on port 9000. It creates a docker volume mapped to the /data directory. Minio server is then started with that volume as the data directory for the application.

  • No labels