postgresql-ha

by Helm

Helm chartv7.5.1App 11.12.0

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/postgresql with bitnami/postgresql-repmgr which 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.

ParameterDescriptionDefault
Global
global.imageRegistryGlobal Docker image registrynil
global.imagePullSecretsGlobal Docker registry secret names as an array[] (does not add image pull secrets to deployed pods)
global.storageClassGlobal storage class for dynamic provisioningnil
global.postgresql.existingSecretName of existing secret to use for PostgreSQL passwords (overrides postgresql.existingSecret)nil
global.postgresql.usernamePostgreSQL username (overrides postgresql.username)nil
global.postgresql.passwordPostgreSQL password (overrides postgresql.password)nil
global.postgresql.databasePostgreSQL database (overrides postgresql.database)nil
global.postgresql.repmgrUsernamePostgreSQL repmgr username (overrides postgresql.repmgrUsername)nil
global.postgresql.repmgrPasswordPostgreSQL repmgr password (overrides postgresql.repmgrpassword)nil
global.postgresql.repmgrDatabasePostgreSQL repmgr database (overrides postgresql.repmgrDatabase)nil
global.ldap.existingSecretName of existing secret to use for LDAP passwords (overrides ldap.existingSecret)nil
global.ldap.bindpwLDAP bind password (overrides ldap.bindpw)nil
global.pgpool.adminUsernamePgpool Admin username (overrides pgpool.adminUsername)nil
global.pgpool.adminPasswordPgpool Admin password (overrides pgpool.adminPassword)nil
General
commonLabelsLabels to add to all deployed objectsnil
commonAnnotationsAnnotations to add to all deployed objects[]
nameOverrideString to partially override postgres-ha.fullname template with a stringnil
fullnameOverrideString to fully override postgres-ha.fullname template with a stringnil
clusterDomainDefault Kubernetes cluster domaincluster.local
extraDeployArray of extra objects to deploy with the release (evaluated as a template).nil
serviceAccount.enabledEnable service account (Note: Service Account will only be automatically created if serviceAccount.name is not set)false
serviceAccount.nameName of existing service accountnil
PostgreSQL with Repmgr
postgresqlImage.registryRegistry for PostgreSQL with Repmgr imagedocker.io
postgresqlImage.repositoryRepository for PostgreSQL with Repmgr imagebitnami/postgresql-repmgr
postgresqlImage.tagTag for PostgreSQL with Repmgr image{TAG_NAME}
postgresqlImage.pullPolicyPostgreSQL with Repmgr image pull policyIfNotPresent
postgresqlImage.pullSecretsSpecify docker-registry secret names as an array[] (does not add image pull secrets to deployed pods)
postgresqlImage.debugSpecify if debug logs should be enabledfalse
postgresql.hostAliasesAdd deployment host aliases[]
postgresql.labelsMap of labels to add to the statefulset. Evaluated as a template{}
postgresql.podLabelsMap of labels to add to the pods. Evaluated as a template{}
postgresql.replicaCountThe number of replicas to deploy2
postgresql.updateStrategyTypeStatefulset update strategy policyRollingUpdate
postgresql.podAnnotationsAdditional pod annotations{}
postgresql.priorityClassNamePod 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartpostgresql-ha is pinned at v7.5.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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