postgresql-ha
by [riftbit]
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
Global parameters
| Name | Description | Value |
|---|---|---|
global.imageRegistry | Global Docker image registry | "" |
global.imagePullSecrets | Global Docker registry secret names as an array | [] |
global.storageClass | Global StorageClass for Persistent Volume(s) | "" |
global.postgresql.username | PostgreSQL username (overrides postgresql.username) | "" |
global.postgresql.password | PostgreSQL password (overrides postgresql.password) | "" |
global.postgresql.database | PostgreSQL database (overrides postgresql.database) | "" |
global.postgresql.repmgrUsername | PostgreSQL repmgr username (overrides postgresql.repmgrUsername) | "" |
global.postgresql.repmgrPassword | PostgreSQL repmgr password (overrides postgresql.repmgrpassword) | "" |
global.postgresql.repmgrDatabase | PostgreSQL repmgr database (overrides postgresql.repmgrDatabase) | "" |
global.postgresql.existingSecret | Name of existing secret to use for PostgreSQL passwords (overrides postgresql.existingSecret) | "" |
global.ldap.bindpw | LDAP bind password (overrides ldap.bindpw) | "" |
global.ldap.existingSecret | Name of existing secret to use for LDAP passwords (overrides ldap.existingSecret) | "" |
global.pgpool.adminUsername | Pgpool Admin username (overrides pgpool.adminUsername) | "" |
global.pgpool.adminPassword | Pgpool Admin password (overrides pgpool.adminPassword) | "" |
global.pgpool.existingSecret | Pgpool existing secret | "" |
General parameters
| Name | Description | Value |
|---|---|---|
nameOverride | String to partially override common.names.fullname template (will maintain the release name) | "" |
fullnameOverride | String to fully override common.names.fullname template | "" |
clusterDomain | Kubernetes Cluster Domain | cluster.local |
commonAnnotations | Common annotations to add to all resources (sub-charts are not considered). Evaluated as a template | {} |
commonLabels | Common labels to add to all resources (sub-charts are not considered). Evaluated as a template | {} |
extraDeploy | Array of extra objects to deploy with the release (evaluated as a template) | [] |
serviceAccount.enabled | Enable service account (Note: Service Account will only be automatically created if serviceAccount.name is not set) | false |
serviceAccount.name | Name of an already existing service account. Setting this value disables the automatic service account creation | "" |
diagnosticMode.enabled | Enable diagnostic mode (all probes will be disabled and the command will be overridden) | false |
diagnosticMode.command | Command to override all containers in the deployment | [] |
diagnosticMode.args | Args to override all containers in the deployment | [] |
PostgreSQL with Repmgr parameters
| Name | Description | Value |
|---|---|---|
postgresqlImage.registry | PostgreSQL with Repmgr image registry | docker.io |
postgresqlImage.repository | PostgreSQL with Repmgr image repository | bitnami/postgresql-repmgr |
postgresqlImage.tag | PostgreSQL with Repmgr image tag | 11.13.0-debian-10-r40 |
postgresqlImage.pullPolicy | PostgreSQL with Repmgr image pull policy | IfNotPresent |
postgresqlImage.pullSecrets | Specify docker-registry secret names as an array | [] |
postgresqlImage.debug | Specify if debug logs should be enabled | false |
postgresql.labels | Labels to add to the StatefulSet. Evaluated as template | {} |
postgresql.podLabels | Labels to add to the StatefulSet pods. Evaluated as template | {} |
postgresql.replicaCount | Number of replicas to deploy | 2 |
postgresql.updateStrategyType | Update strategy for PostgreSQL statefulset | RollingUpdate |
postgresql.hostAliases | Deployment pod host aliases | [] |
postgresql.podAnnotations | Additional pod annotations | {} |
postgresql.priorityClassName | Pod priority class | "" |
postgresql.podAffinityPreset | PostgreSQL pod affinity preset. Ignored if postgresql.affinity is set. Allowed values: soft or hard | "" |
postgresql.podAntiAffinityPreset | PostgreSQL pod anti-affinity preset. Ignored if postgresql.affinity is set. Allowed values: soft or hard | soft |
postgresql.nodeAffinityPreset.type | PostgreSQL node affinity preset type. Ignored if postgresql.affinity is set. Allowed values: soft or hard | "" |
postgresql.nodeAffinityPreset.key | PostgreSQL node label key to match Ignored if postgresql.affinity is set. | "" |
postgresql.nodeAffinityPreset.values | PostgreSQL node label values to match. Ignored if postgresql.affinity is set. | [] |
postgresql.affinity | Affinity for PostgreSQL pods assignment | {} |
postgresql.nodeSelector | Node labels for PostgreSQL pods assignment | {} |
postgresql.tolerations | Tolerations for PostgreSQL pods assignment | [] |
postgresql.securityContext.enabled | Enable security context for PostgreSQL with Repmgr | true |
postgresql.securityContext.fsGroup | Group ID for the PostgreSQL with Repmgr filesystem | 1001 |
postgresql.containerSecurityContext.enabled | Enable container security context | true |
postgresql.containerSecurityContext.runAsUser | User ID for the PostgreSQL with Repmgr container |
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.9.6 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