postgresql-ha

by [riftbit]

Helm chartv7.9.6App 11.13.0Verified publisher

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

Global parameters

NameDescriptionValue
global.imageRegistryGlobal Docker image registry""
global.imagePullSecretsGlobal Docker registry secret names as an array[]
global.storageClassGlobal StorageClass for Persistent Volume(s)""
global.postgresql.usernamePostgreSQL username (overrides postgresql.username)""
global.postgresql.passwordPostgreSQL password (overrides postgresql.password)""
global.postgresql.databasePostgreSQL database (overrides postgresql.database)""
global.postgresql.repmgrUsernamePostgreSQL repmgr username (overrides postgresql.repmgrUsername)""
global.postgresql.repmgrPasswordPostgreSQL repmgr password (overrides postgresql.repmgrpassword)""
global.postgresql.repmgrDatabasePostgreSQL repmgr database (overrides postgresql.repmgrDatabase)""
global.postgresql.existingSecretName of existing secret to use for PostgreSQL passwords (overrides postgresql.existingSecret)""
global.ldap.bindpwLDAP bind password (overrides ldap.bindpw)""
global.ldap.existingSecretName of existing secret to use for LDAP passwords (overrides ldap.existingSecret)""
global.pgpool.adminUsernamePgpool Admin username (overrides pgpool.adminUsername)""
global.pgpool.adminPasswordPgpool Admin password (overrides pgpool.adminPassword)""
global.pgpool.existingSecretPgpool existing secret""

General parameters

NameDescriptionValue
nameOverrideString to partially override common.names.fullname template (will maintain the release name)""
fullnameOverrideString to fully override common.names.fullname template""
clusterDomainKubernetes Cluster Domaincluster.local
commonAnnotationsCommon annotations to add to all resources (sub-charts are not considered). Evaluated as a template{}
commonLabelsCommon labels to add to all resources (sub-charts are not considered). Evaluated as a template{}
extraDeployArray of extra objects to deploy with the release (evaluated as a template)[]
serviceAccount.enabledEnable service account (Note: Service Account will only be automatically created if serviceAccount.name is not set)false
serviceAccount.nameName of an already existing service account. Setting this value disables the automatic service account creation""
diagnosticMode.enabledEnable diagnostic mode (all probes will be disabled and the command will be overridden)false
diagnosticMode.commandCommand to override all containers in the deployment[]
diagnosticMode.argsArgs to override all containers in the deployment[]

PostgreSQL with Repmgr parameters

NameDescriptionValue
postgresqlImage.registryPostgreSQL with Repmgr image registrydocker.io
postgresqlImage.repositoryPostgreSQL with Repmgr image repositorybitnami/postgresql-repmgr
postgresqlImage.tagPostgreSQL with Repmgr image tag11.13.0-debian-10-r40
postgresqlImage.pullPolicyPostgreSQL with Repmgr image pull policyIfNotPresent
postgresqlImage.pullSecretsSpecify docker-registry secret names as an array[]
postgresqlImage.debugSpecify if debug logs should be enabledfalse
postgresql.labelsLabels to add to the StatefulSet. Evaluated as template{}
postgresql.podLabelsLabels to add to the StatefulSet pods. Evaluated as template{}
postgresql.replicaCountNumber of replicas to deploy2
postgresql.updateStrategyTypeUpdate strategy for PostgreSQL statefulsetRollingUpdate
postgresql.hostAliasesDeployment pod host aliases[]
postgresql.podAnnotationsAdditional pod annotations{}
postgresql.priorityClassNamePod priority class""
postgresql.podAffinityPresetPostgreSQL pod affinity preset. Ignored if postgresql.affinity is set. Allowed values: soft or hard""
postgresql.podAntiAffinityPresetPostgreSQL pod anti-affinity preset. Ignored if postgresql.affinity is set. Allowed values: soft or hardsoft
postgresql.nodeAffinityPreset.typePostgreSQL node affinity preset type. Ignored if postgresql.affinity is set. Allowed values: soft or hard""
postgresql.nodeAffinityPreset.keyPostgreSQL node label key to match Ignored if postgresql.affinity is set.""
postgresql.nodeAffinityPreset.valuesPostgreSQL node label values to match. Ignored if postgresql.affinity is set.[]
postgresql.affinityAffinity for PostgreSQL pods assignment{}
postgresql.nodeSelectorNode labels for PostgreSQL pods assignment{}
postgresql.tolerationsTolerations for PostgreSQL pods assignment[]
postgresql.securityContext.enabledEnable security context for PostgreSQL with Repmgrtrue
postgresql.securityContext.fsGroupGroup ID for the PostgreSQL with Repmgr filesystem1001
postgresql.containerSecurityContext.enabledEnable container security contexttrue
postgresql.containerSecurityContext.runAsUserUser 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.

  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.9.6 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