postgresql-ha
by Helm
Chart for PostgreSQL with HA architecture (using Replication Manager (repmgr) and Pgpool).
About this chart
PostgreSQL HA
This Helm chart has been developed based on bitnami/postgresql chart but including some changes to guarantee high availability such as:
- A new deployment, service have been added to deploy Pgpool-II to act as proxy for PostgreSQL backend. It helps to reduce connection overhead, acts as a load balancer for PostgreSQL, and ensures database node failover.
- Replacing
bitnami/postgresqlwithbitnami/postgresql-repmgrwhich includes and configures repmgr. Repmgr ensures standby nodes assume the primary role when the primary node is unhealthy.
TL;DR
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install my-release bitnami/postgresql-ha
Introduction
This Helm chart installs PostgreSQL with HA architecture in a Kubernetes cluster. Welcome to contribute to Helm Chart for PostgreSQL HA.
Prerequisites
- Kubernetes 1.12+
- Helm 3.1.0
Installing the Chart
Install the PostgreSQL HA helm chart with a release name my-release:
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install my-release bitnami/postgresql-ha
Uninstalling the Chart
To uninstall/delete the my-release deployment:
$ helm delete --purge my-release
Additionally, if persistence.resourcePolicy is set to keep, you should manually delete the PVCs.
Parameters
The following table lists the configurable parameters of the PostgreSQL HA chart and the default values. They can be configured in values.yaml or set via --set flag during installation.
| Parameter | Description | Default |
|---|---|---|
| Global | ||
global.imageRegistry | Global Docker image registry | nil |
global.imagePullSecrets | Global Docker registry secret names as an array | [] (does not add image pull secrets to deployed pods) |
global.storageClass | Global storage class for dynamic provisioning | nil |
global.postgresql.existingSecret | Name of existing secret to use for PostgreSQL passwords (overrides postgresql.existingSecret) | nil |
global.postgresql.username | PostgreSQL username (overrides postgresql.username) | nil |
global.postgresql.password | PostgreSQL password (overrides postgresql.password) | nil |
global.postgresql.database | PostgreSQL database (overrides postgresql.database) | nil |
global.postgresql.repmgrUsername | PostgreSQL repmgr username (overrides postgresql.repmgrUsername) | nil |
global.postgresql.repmgrPassword | PostgreSQL repmgr password (overrides postgresql.repmgrpassword) | nil |
global.postgresql.repmgrDatabase | PostgreSQL repmgr database (overrides postgresql.repmgrDatabase) | nil |
global.ldap.existingSecret | Name of existing secret to use for LDAP passwords (overrides ldap.existingSecret) | nil |
global.ldap.bindpw | LDAP bind password (overrides ldap.bindpw) | nil |
global.pgpool.adminUsername | Pgpool Admin username (overrides pgpool.adminUsername) | nil |
global.pgpool.adminPassword | Pgpool Admin password (overrides pgpool.adminPassword) | nil |
| General | ||
commonLabels | Labels to add to all deployed objects | nil |
commonAnnotations | Annotations to add to all deployed objects | [] |
nameOverride | String to partially override postgres-ha.fullname template with a string | nil |
fullnameOverride | String to fully override postgres-ha.fullname template with a string | nil |
clusterDomain | Default Kubernetes cluster domain | cluster.local |
extraDeploy | Array of extra objects to deploy with the release (evaluated as a template). | nil |
serviceAccount.enabled | Enable service account (Note: Service Account will only be automatically created if serviceAccount.name is not set) | false |
serviceAccount.name | Name of existing service account | nil |
| PostgreSQL with Repmgr | ||
postgresqlImage.registry | Registry for PostgreSQL with Repmgr image | docker.io |
postgresqlImage.repository | Repository for PostgreSQL with Repmgr image | bitnami/postgresql-repmgr |
postgresqlImage.tag | Tag for PostgreSQL with Repmgr image | {TAG_NAME} |
postgresqlImage.pullPolicy | PostgreSQL with Repmgr image pull policy | IfNotPresent |
postgresqlImage.pullSecrets | Specify docker-registry secret names as an array | [] (does not add image pull secrets to deployed pods) |
postgresqlImage.debug | Specify if debug logs should be enabled | false |
postgresql.hostAliases | Add deployment host aliases | [] |
postgresql.labels | Map of labels to add to the statefulset. Evaluated as a template | {} |
postgresql.podLabels | Map of labels to add to the pods. Evaluated as a template | {} |
postgresql.replicaCount | The number of replicas to deploy | 2 |
postgresql.updateStrategyType | Statefulset update strategy policy | RollingUpdate |
postgresql.podAnnotations | Additional pod annotations | {} |
postgresql.priorityClassName | Pod priority class |
Deploy postgresql-ha with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has postgresql-ha on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartpostgresql-ha is pinned at v7.5.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply