pgbouncer

by pmint93

Helm chartv0.10.0App v1.21.0

A Helm chart for Pgbouncer

About this chart

PgBouncer

A helm chart for PgBouncer - the lightweight connection pooler for PostgreSQL

Introduction

This chart bootstraps a PgBouncer deployment on a Kubernetes cluster using the Helm package manager.

Get Repo Info

helm repo add pmint93 https://pmint93.github.io/helm-charts
helm repo update

See helm repo for command documentation.

Installing the Chart

helm install [RELEASE_NAME] pmint93/pgbouncer

Uninstalling the Chart

helm uninstall [RELEASE_NAME]

Configuration

The following table lists the configurable parameters of the chart and their default values.

KeyTypeDefaultDescription
replicaCountint1Desired number of pods
databasesobject{}List of databases that PgBouncer will route to
userslist[]List of users and specific settings
connectionLimits.default_pool_sizeint20Number of server connections per user/database pair
connectionLimits.max_client_connint200Maximum number of client connections allowed
connectionLimits.min_pool_sizeint15Add more server connections to pool if below this number
connectionLimits.reserve_pool_sizeint25How many additional connections to allow to a pool
connectionLimits.reserve_pool_timeoutint5If a client has not been serviced in this time, use additional connections from the reserve pool
logging.log_connectionsint1Log successful logins
logging.log_disconnectionsint1Log disconnections with reasons
logging.log_pooler_errorsint1Log error messages the pooler sends to clients
logging.log_statsint0Write aggregated statistics into the log, every stats_period
logging.stats_periodint60Set how often aggregated statistics are written to the log
logging.verboseint0Verbosity level
settings.auth_querystring"SELECT usename, passwd FROM pg_shadow WHERE usename=$1"Query to load user’s password from database
settings.auth_typestring"md5"How to authenticate users: cert, md5, scram-sha-256, plain, plain, any, hba or pam
settings.auth_userstringnilIf set, then any user not specified in users will be queried through the auth_query
settings.pool_modestring"session"Set the pool mode to be used for all connections
extraSettingsobject{"ignore_startup_parameters":"extra_float_digits"}Extra settings for section [pgbouncer] in pgbouncer.ini
image.commandlist[]Override the image's command
image.argslist["/etc/pgbouncer/pgbouncer.ini"]Container image args
image.pullPolicystring"IfNotPresent"Container image pull policy
image.repositorystring"hyperized/pgbouncer"Container image repository
image.tagstringchart's appVersionContainer image tag
imagePullSecretslist[]Container image pull secrets
nameOverridestring""Override the name of release
fullnameOverridestring""Override the fullname of release
deploymentAnnotationsobject{}Deployment's annotations
podAnnotationsobject{}Pod's annotations
podSecurityContextobject{}Security context settings for the pod
securityContextobject{}Security context settings for the container
updateStrategyobject{"type":"RollingUpdate","rollingUpdate":{"maxUnavailable":0}}The deployment update strategy settings
service.portint5432Service external port
service.typestring"ClusterIP"ClusterIP, NodePort, or LoadBalancer
resourcesobject{}Server resource requests and limits
nodeSelectorobject{}Node labels for pod assignment
tolerationslist[]Toleration labels for pod assignment
affinityobject{}Affinity settings for pod assignment
topologySpreadConstraintslist[]Topology spread constraints for pod assignment
serviceAccountobject{enable: false}Service account's definition
serviceAccount.enableboolfalseService account's section flag
serviceAccount.namestring"pgbouncer"Service account's name
serviceAccount.annotationsobject{}Service account's annotations
sidecarslist[]Sidecars raw definition
serviceAccount.existingServiceAccountNamestring""Do not create a KSA but use an existing one

To better understand PgBouncer configuration, please refer to this document

Deploy pgbouncer with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has pgbouncer 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 chartpgbouncer is pinned at v0.10.0 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