Back to Charts

PostgreSQL

stable/postgresql/README.md

latest66.7 KB
Original Source

PostgreSQL

PostgreSQL is an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance.

For HA, please see this repo

This Helm chart is deprecated

Given the stable deprecation timeline, the Bitnami maintained PostgreSQL Helm chart is now located at bitnami/charts.

The Bitnami repository is already included in the Hubs and we will continue providing the same cadence of updates, support, etc that we've been keeping here these years. Installation instructions are very similar, just adding the bitnami repo and using it during the installation (bitnami/<chart> instead of stable/<chart>)

bash
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install my-release bitnami/<chart>           # Helm 3
$ helm install --name my-release bitnami/<chart>    # Helm 2

To update an exisiting stable deployment with a chart hosted in the bitnami repository you can execute

bash
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm upgrade my-release bitnami/<chart>

Issues and PRs related to the chart itself will be redirected to bitnami/charts GitHub repository. In the same way, we'll be happy to answer questions related to this migration process in this issue created as a common place for discussion.

TL;DR;

console
$ helm install my-release stable/postgresql

Introduction

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

Bitnami charts can be used with Kubeapps for deployment and management of Helm Charts in clusters. This chart has been tested to work with NGINX Ingress, cert-manager, fluentd and Prometheus on top of the BKPR.

Prerequisites

  • Kubernetes 1.12+
  • Helm 2.11+ or Helm 3.0-beta3+
  • PV provisioner support in the underlying infrastructure

Installing the Chart

To install the chart with the release name my-release:

console
$ helm install my-release stable/postgresql

The command deploys PostgreSQL on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the my-release deployment:

console
$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Parameters

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

ParameterDescriptionDefault
global.imageRegistryGlobal Docker Image registrynil
global.postgresql.postgresqlDatabasePostgreSQL database (overrides postgresqlDatabase)nil
global.postgresql.postgresqlUsernamePostgreSQL username (overrides postgresqlUsername)nil
global.postgresql.existingSecretName of existing secret to use for PostgreSQL passwords (overrides existingSecret)nil
global.postgresql.postgresqlPasswordPostgreSQL admin password (overrides postgresqlPassword)nil
global.postgresql.servicePortPostgreSQL port (overrides service.port)nil
global.postgresql.replicationPasswordReplication user password (overrides replication.password)nil
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
image.registryPostgreSQL Image registrydocker.io
image.repositoryPostgreSQL Image namebitnami/postgresql
image.tagPostgreSQL Image tag{TAG_NAME}
image.pullPolicyPostgreSQL Image pull policyIfNotPresent
image.pullSecretsSpecify Image pull secretsnil (does not add image pull secrets to deployed pods)
image.debugSpecify if debug values should be setfalse
nameOverrideString to partially override postgresql.fullname template with a string (will prepend the release name)nil
fullnameOverrideString to fully override postgresql.fullname template with a stringnil
volumePermissions.enabledEnable init container that changes volume permissions in the data directory (for cases where the default k8s runAsUser and fsUser values do not work)false
volumePermissions.image.registryInit container volume-permissions image registrydocker.io
volumePermissions.image.repositoryInit container volume-permissions image namebitnami/minideb
volumePermissions.image.tagInit container volume-permissions image tagbuster
volumePermissions.image.pullPolicyInit container volume-permissions image pull policyAlways
volumePermissions.securityContext.runAsUserUser ID for the init container (when facing issues in OpenShift or uid unknown, try value "auto")0
usePasswordFileHave the secrets mounted as a file instead of env varsfalse
ldap.enabledEnable LDAP supportfalse
ldap.existingSecretName of existing secret to use for LDAP passwordsnil
ldap.urlLDAP URL beginning in the form ldap[s]://host[:port]/basedn[?[attribute][?[scope][?[filter]]]]nil
ldap.serverIP address or name of the LDAP server.nil
ldap.portPort number on the LDAP server to connect tonil
ldap.schemeSet to ldaps to use LDAPS.nil
ldap.tlsSet to 1 to use TLS encryptionnil
ldap.prefixString to prepend to the user name when forming the DN to bindnil
ldap.suffixString to append to the user name when forming the DN to bindnil
ldap.search_attrAttribute to match agains the user name in the searchnil
ldap.search_filterThe search filter to use when doing search+bind authenticationnil
ldap.baseDNRoot DN to begin the search for the user innil
ldap.bindDNDN of user to bind to LDAPnil
ldap.bind_passwordPassword for the user to bind to LDAPnil
replication.enabledEnable replicationfalse
replication.userReplication userrepl_user
replication.passwordReplication user passwordrepl_password
replication.slaveReplicasNumber of slaves replicas1
replication.synchronousCommitSet synchronous commit mode. Allowed values: on, remote_apply, remote_write, local and offoff
replication.numSynchronousReplicasNumber of replicas that will have synchronous replication. Note: Cannot be greater than replication.slaveReplicas.0
replication.applicationNameCluster application name. Useful for advanced replication settingsmy_application
existingSecretName of existing secret to use for PostgreSQL passwords. The secret has to contain the keys postgresql-postgres-password which is the password for postgresqlUsername when it is different of postgres, postgresql-password which will override postgresqlPassword, postgresql-replication-password which will override replication.password and postgresql-ldap-password which will be sed to authenticate on LDAP.nil
postgresqlPostgresPasswordPostgreSQL admin password (used when postgresqlUsername is not postgres)random 10 character alphanumeric string
postgresqlUsernamePostgreSQL admin userpostgres
postgresqlPasswordPostgreSQL admin passwordrandom 10 character alphanumeric string
postgresqlDatabasePostgreSQL databasenil
postgresqlDataDirPostgreSQL data dir folder/bitnami/postgresql (same value as persistence.mountPath)
extraEnvAny extra environment variables you would like to pass on to the pod. The value is evaluated as a template.[]
extraEnvVarsCMName of a Config Map containing extra environment variables you would like to pass on to the pod.nil
postgresqlInitdbArgsPostgreSQL initdb extra argumentsnil
postgresqlInitdbWalDirPostgreSQL location for transaction lognil
postgresqlConfigurationRuntime Config Parametersnil
postgresqlExtendedConfExtended Runtime Config Parameters (appended to main or default configuration)nil
pgHbaConfigurationContent of pg_hba.confnil (do not create pg_hba.conf)
configurationConfigMapConfigMap with the PostgreSQL configuration files (Note: Overrides postgresqlConfiguration and pgHbaConfiguration). The value is evaluated as a template.nil
extendedConfConfigMapConfigMap with the extended PostgreSQL configuration files. The value is evaluated as a template.nil
initdbScriptsDictionary of initdb scriptsnil
initdbUsernamePostgreSQL user to execute the .sql and sql.gz scriptsnil
initdbPasswordPassword for the user specified in initdbUsernamenil
initdbScriptsConfigMapConfigMap with the initdb scripts (Note: Overrides initdbScripts). The value is evaluated as a template.nil
initdbScriptsSecretSecret with initdb scripts that contain sensitive information (Note: can be used with initdbScriptsConfigMap or initdbScripts). The value is evaluated as a template.nil
service.typeKubernetes Service typeClusterIP
service.portPostgreSQL port5432
service.nodePortKubernetes Service nodePortnil
service.annotationsAnnotations for PostgreSQL service, the value is evaluated as a template.{}
service.loadBalancerIPloadBalancerIP if service type is LoadBalancernil
service.loadBalancerSourceRangesAddress that are allowed when svc is LoadBalancer[]
schedulerNameName of the k8s scheduler (other than default)nil
shmVolume.enabledEnable emptyDir volume for /dev/shm for master and slave(s) Pod(s)true
shmVolume.chmod.enabledRun at init chmod 777 of the /dev/shm (ignored if volumePermissions.enabled is false)true
persistence.enabledEnable persistence using PVCtrue
persistence.existingClaimProvide an existing PersistentVolumeClaim, the value is evaluated as a template.nil
persistence.mountPathPath to mount the volume at/bitnami/postgresql
persistence.subPathSubdirectory of the volume to mount at""
persistence.storageClassPVC Storage Class for PostgreSQL volumenil
persistence.accessModesPVC Access Mode for PostgreSQL volume[ReadWriteOnce]
persistence.sizePVC Storage Request for PostgreSQL volume8Gi
persistence.annotationsAnnotations for the PVC{}
master.nodeSelectorNode labels for pod assignment (postgresql master){}
master.affinityAffinity labels for pod assignment (postgresql master){}
master.tolerationsToleration labels for pod assignment (postgresql master)[]
master.anotationsMap of annotations to add to the statefulset (postgresql master){}
master.labelsMap of labels to add to the statefulset (postgresql master){}
master.podAnnotationsMap of annotations to add to the pods (postgresql master){}
master.podLabelsMap of labels to add to the pods (postgresql master){}
master.priorityClassNamePriority Class to use for each pod (postgresql master)nil
master.extraInitContainersAdditional init containers to add to the pods (postgresql master)[]
master.extraVolumeMountsAdditional volume mounts to add to the pods (postgresql master)[]
master.extraVolumesAdditional volumes to add to the pods (postgresql master)[]
master.sidecarsAdd additional containers to the pod[]
slave.nodeSelectorNode labels for pod assignment (postgresql slave){}
slave.affinityAffinity labels for pod assignment (postgresql slave){}
slave.tolerationsToleration labels for pod assignment (postgresql slave)[]
slave.anotationsMap of annotations to add to the statefulsets (postgresql slave){}
slave.labelsMap of labels to add to the statefulsets (postgresql slave){}
slave.podAnnotationsMap of annotations to add to the pods (postgresql slave){}
slave.podLabelsMap of labels to add to the pods (postgresql slave){}
slave.priorityClassNamePriority Class to use for each pod (postgresql slave)nil
slave.extraInitContainersAdditional init containers to add to the pods (postgresql slave)[]
slave.extraVolumeMountsAdditional volume mounts to add to the pods (postgresql slave)[]
slave.extraVolumesAdditional volumes to add to the pods (postgresql slave)[]
slave.sidecarsAdd additional containers to the pod[]
terminationGracePeriodSecondsSeconds the pod needs to terminate gracefullynil
resourcesCPU/Memory resource requests/limitsMemory: 256Mi, CPU: 250m
securityContext.enabledEnable security contexttrue
securityContext.fsGroupGroup ID for the container1001
securityContext.runAsUserUser ID for the container1001
serviceAccount.enabledEnable service account (Note: Service Account will only be automatically created if serviceAccount.name is not set)false
serviceAcccount.nameName of existing service accountnil
livenessProbe.enabledWould you like a livenessProbe to be enabledtrue
networkPolicy.enabledEnable NetworkPolicyfalse
networkPolicy.allowExternalDon't require client label for connectionstrue
networkPolicy.explicitNamespacesSelectorA Kubernetes LabelSelector to explicitly select namespaces from which ingress traffic could be allowednil
livenessProbe.initialDelaySecondsDelay before liveness probe is initiated30
livenessProbe.periodSecondsHow often to perform the probe10
livenessProbe.timeoutSecondsWhen the probe times out5
livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.6
livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed1
readinessProbe.enabledwould you like a readinessProbe to be enabledtrue
readinessProbe.initialDelaySecondsDelay before readiness probe is initiated5
readinessProbe.periodSecondsHow often to perform the probe10
readinessProbe.timeoutSecondsWhen the probe times out5
readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.6
readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed1
metrics.enabledStart a prometheus exporterfalse
metrics.service.typeKubernetes Service typeClusterIP
service.clusterIPStatic clusterIP or None for headless servicesnil
metrics.service.annotationsAdditional annotations for metrics exporter pod{ prometheus.io/scrape: "true", prometheus.io/port: "9187"}
metrics.service.loadBalancerIPloadBalancerIP if redis metrics service type is LoadBalancernil
metrics.serviceMonitor.enabledSet this to true to create ServiceMonitor for Prometheus operatorfalse
metrics.serviceMonitor.additionalLabelsAdditional labels that can be used so ServiceMonitor will be discovered by Prometheus{}
metrics.serviceMonitor.namespaceOptional namespace in which to create ServiceMonitornil
metrics.serviceMonitor.intervalScrape interval. If not set, the Prometheus default scrape interval is usednil
metrics.serviceMonitor.scrapeTimeoutScrape timeout. If not set, the Prometheus default scrape timeout is usednil
metrics.prometheusRule.enabledSet this to true to create prometheusRules for Prometheus operatorfalse
metrics.prometheusRule.additionalLabelsAdditional labels that can be used so prometheusRules will be discovered by Prometheus{}
metrics.prometheusRule.namespacenamespace where prometheusRules resource should be createdthe same namespace as postgresql
metrics.prometheusRule.rulesrules to be created, check values for an example.[]
metrics.image.registryPostgreSQL Image registrydocker.io
metrics.image.repositoryPostgreSQL Image namebitnami/postgres-exporter
metrics.image.tagPostgreSQL Image tag{TAG_NAME}
metrics.image.pullPolicyPostgreSQL Image pull policyIfNotPresent
metrics.image.pullSecretsSpecify Image pull secretsnil (does not add image pull secrets to deployed pods)
metrics.customMetricsAdditional custom metricsnil
metrics.securityContext.enabledEnable security context for metricsfalse
metrics.securityContext.runAsUserUser ID for the container for metrics1001
metrics.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated30
metrics.livenessProbe.periodSecondsHow often to perform the probe10
metrics.livenessProbe.timeoutSecondsWhen the probe times out5
metrics.livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.6
metrics.livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed1
metrics.readinessProbe.enabledwould you like a readinessProbe to be enabledtrue
metrics.readinessProbe.initialDelaySecondsDelay before liveness probe is initiated5
metrics.readinessProbe.periodSecondsHow often to perform the probe10
metrics.readinessProbe.timeoutSecondsWhen the probe times out5
metrics.readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.6
metrics.readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed1
updateStrategyUpdate strategy policy{type: "RollingUpdate"}

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

console
$ helm install my-release \
  --set postgresqlPassword=secretpassword,postgresqlDatabase=my-database \
    stable/postgresql

The above command sets the PostgreSQL postgres account password to secretpassword. Additionally it creates a database named my-database.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

console
$ helm install my-release -f values.yaml stable/postgresql

Tip: You can use the default values.yaml

Configuration and installation details

Rolling VS Immutable tags

It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.

Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.

Production configuration and horizontal scaling

This chart includes a values-production.yaml file where you can find some parameters oriented to production configuration in comparison to the regular values.yaml. You can use this file instead of the default one.

  • Enable replication:
diff
- replication.enabled: false
+ replication.enabled: true
  • Number of slaves replicas:
diff
- replication.slaveReplicas: 1
+ replication.slaveReplicas: 2
  • Set synchronous commit mode:
diff
- replication.synchronousCommit: "off"
+ replication.synchronousCommit: "on"
  • Number of replicas that will have synchronous replication:
diff
- replication.numSynchronousReplicas: 0
+ replication.numSynchronousReplicas: 1
  • Start a prometheus exporter:
diff
- metrics.enabled: false
+ metrics.enabled: true

To horizontally scale this chart, you can use the --replicas flag to modify the number of nodes in your PostgreSQL deployment. Also you can use the values-production.yaml file or modify the parameters shown above.

Change PostgreSQL version

To modify the PostgreSQL version used in this chart you can specify a valid image tag using the image.tag parameter. For example, image.tag=12.0.0

postgresql.conf / pg_hba.conf files as configMap

This helm chart also supports to customize the whole configuration file.

Add your custom file to "files/postgresql.conf" in your working directory. This file will be mounted as configMap to the containers and it will be used for configuring the PostgreSQL server.

Alternatively, you can specify PostgreSQL configuration parameters using the postgresqlConfiguration parameter as a dict, using camelCase, e.g. {"sharedBuffers": "500MB"}.

In addition to these options, you can also set an external ConfigMap with all the configuration files. This is done by setting the configurationConfigMap parameter. Note that this will override the two previous options.

Allow settings to be loaded from files other than the default postgresql.conf

If you don't want to provide the whole PostgreSQL configuration file and only specify certain parameters, you can add your extended .conf files to "files/conf.d/" in your working directory. Those files will be mounted as configMap to the containers adding/overwriting the default configuration using the include_dir directive that allows settings to be loaded from files other than the default postgresql.conf.

Alternatively, you can also set an external ConfigMap with all the extra configuration files. This is done by setting the extendedConfConfigMap parameter. Note that this will override the previous option.

Initialize a fresh instance

The Bitnami PostgreSQL image allows you to use your custom scripts to initialize a fresh instance. In order to execute the scripts, they must be located inside the chart folder files/docker-entrypoint-initdb.d so they can be consumed as a ConfigMap.

Alternatively, you can specify custom scripts using the initdbScripts parameter as dict.

In addition to these options, you can also set an external ConfigMap with all the initialization scripts. This is done by setting the initdbScriptsConfigMap parameter. Note that this will override the two previous options. If your initialization scripts contain sensitive information such as credentials or passwords, you can use the initdbScriptsSecret parameter.

The allowed extensions are .sh, .sql and .sql.gz.

Sidecars

If you need additional containers to run within the same pod as PostgreSQL (e.g. an additional metrics or logging exporter), you can do so via the sidecars config parameter. Simply define your container according to the Kubernetes container spec.

yaml
# For the PostgreSQL master
master:
  sidecars:
  - name: your-image-name
    image: your-image
    imagePullPolicy: Always
    ports:
    - name: portname
     containerPort: 1234
# For the PostgreSQL replicas
slave:
  sidecars:
  - name: your-image-name
    image: your-image
    imagePullPolicy: Always
    ports:
    - name: portname
     containerPort: 1234

Metrics

The chart optionally can start a metrics exporter for prometheus. The metrics endpoint (port 9187) is not exposed and it is expected that the metrics are collected from inside the k8s cluster using something similar as the described in the example Prometheus scrape configuration.

The exporter allows to create custom metrics from additional SQL queries. See the Chart's values.yaml for an example and consult the exporters documentation for more details.

Use of global variables

In more complex scenarios, we may have the following tree of dependencies

                     +--------------+
                     |              |
        +------------+   Chart 1    +-----------+
        |            |              |           |
        |            --------+------+           |
        |                    |                  |
        |                    |                  |
        |                    |                  |
        |                    |                  |
        v                    v                  v
+-------+------+    +--------+------+  +--------+------+
|              |    |               |  |               |
|  PostgreSQL  |    |  Sub-chart 1  |  |  Sub-chart 2  |
|              |    |               |  |               |
+--------------+    +---------------+  +---------------+

The three charts below depend on the parent chart Chart 1. However, subcharts 1 and 2 may need to connect to PostgreSQL as well. In order to do so, subcharts 1 and 2 need to know the PostgreSQL credentials, so one option for deploying could be deploy Chart 1 with the following parameters:

postgresql.postgresqlPassword=testtest
subchart1.postgresql.postgresqlPassword=testtest
subchart2.postgresql.postgresqlPassword=testtest
postgresql.postgresqlDatabase=db1
subchart1.postgresql.postgresqlDatabase=db1
subchart2.postgresql.postgresqlDatabase=db1

If the number of dependent sub-charts increases, installing the chart with parameters can become increasingly difficult. An alternative would be to set the credentials using global variables as follows:

global.postgresql.postgresqlPassword=testtest
global.postgresql.postgresqlDatabase=db1

This way, the credentials will be available in all of the subcharts.

Persistence

The Bitnami PostgreSQL image stores the PostgreSQL data and configurations at the /bitnami/postgresql path of the container.

Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube. See the Parameters section to configure the PVC or to disable persistence.

If you already have data in it, you will fail to sync to standby nodes for all commits, details can refer to code. If you need to use those data, please covert them to sql and import after helm install finished.

NetworkPolicy

To enable network policy for PostgreSQL, install a networking plugin that implements the Kubernetes NetworkPolicy spec, and set networkPolicy.enabled to true.

For Kubernetes v1.5 & v1.6, you must also turn on NetworkPolicy by setting the DefaultDeny namespace annotation. Note: this will enforce policy for all pods in the namespace:

console
$ kubectl annotate namespace default "net.beta.kubernetes.io/network-policy={\"ingress\":{\"isolation\":\"DefaultDeny\"}}"

With NetworkPolicy enabled, traffic will be limited to just port 5432.

For more precise policy, set networkPolicy.allowExternal=false. This will only allow pods with the generated client label to connect to PostgreSQL. This label will be displayed in the output of a successful install.

Differences between Bitnami PostgreSQL image and Docker Official image

  • The Docker Official PostgreSQL image does not support replication. If you pass any replication environment variable, this would be ignored. The only environment variables supported by the Docker Official image are POSTGRES_USER, POSTGRES_DB, POSTGRES_PASSWORD, POSTGRES_INITDB_ARGS, POSTGRES_INITDB_WALDIR and PGDATA. All the remaining environment variables are specific to the Bitnami PostgreSQL image.
  • The Bitnami PostgreSQL image is non-root by default. This requires that you run the pod with securityContext and updates the permissions of the volume with an initContainer. A key benefit of this configuration is that the pod follows security best practices and is prepared to run on Kubernetes distributions with hard security constraints like OpenShift.
  • For OpenShift, one may either define the runAsUser and fsGroup accordingly, or try this more dynamic option: volumePermissions.securityContext.runAsUser="auto",securityContext.enabled=false,shmVolume.chmod.enabled=false

Deploy chart using Docker Official PostgreSQL Image

From chart version 4.0.0, it is possible to use this chart with the Docker Official PostgreSQL image. Besides specifying the new Docker repository and tag, it is important to modify the PostgreSQL data directory and volume mount point. Basically, the PostgreSQL data dir cannot be the mount point directly, it has to be a subdirectory.

helm install postgres \
             --set image.repository=postgres \
             --set image.tag=10.6 \
             --set postgresqlDataDir=/data/pgdata \
             --set persistence.mountPath=/data/ \
             stable/postgresql

Upgrade

It's necessary to specify the existing passwords while performing an upgrade to ensure the secrets are not updated with invalid randomly generated passwords. Remember to specify the existing values of the postgresqlPassword and replication.password parameters when upgrading the chart:

bash
$ helm upgrade my-release stable/postgresql \
    --set postgresqlPassword=[POSTGRESQL_PASSWORD] \
    --set replication.password=[REPLICATION_PASSWORD]

Note: you need to substitute the placeholders [POSTGRESQL_PASSWORD], and [REPLICATION_PASSWORD] with the values obtained from instructions in the installation notes.

8.0.0

Prefixes the port names with their protocols to comply with Istio conventions.

If you depend on the port names in your setup, make sure to update them to reflect this change.

7.1.0

Adds support for LDAP configuration.

7.0.0

Helm performs a lookup for the object based on its group (apps), version (v1), and kind (Deployment). Also known as its GroupVersionKind, or GVK. Changing the GVK is considered a compatibility breaker from Kubernetes' point of view, so you cannot "upgrade" those objects to the new GVK in-place. Earlier versions of Helm 3 did not perform the lookup correctly which has since been fixed to match the spec.

In https://github.com/helm/charts/pull/17281 the apiVersion of the statefulset resources was updated to apps/v1 in tune with the api's deprecated, resulting in compatibility breakage.

This major version bump signifies this change.

6.5.7

In this version, the chart will use PostgreSQL with the Postgis extension included. The version used with Postgresql version 10, 11 and 12 is Postgis 2.5. It has been compiled with the following dependencies:

  • protobuf
  • protobuf-c
  • json-c
  • geos
  • proj

5.0.0

In this version, the chart is using PostgreSQL 11 instead of PostgreSQL 10. You can find the main difference and notable changes in the following links: https://www.postgresql.org/about/news/1894/ and https://www.postgresql.org/about/featurematrix/.

For major releases of PostgreSQL, the internal data storage format is subject to change, thus complicating upgrades, you can see some errors like the following one in the logs:

bash
Welcome to the Bitnami postgresql container
Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
Send us your feedback at [email protected]

INFO  ==> ** Starting PostgreSQL setup **
NFO  ==> Validating settings in POSTGRESQL_* env vars..
INFO  ==> Initializing PostgreSQL database...
INFO  ==> postgresql.conf file not detected. Generating it...
INFO  ==> pg_hba.conf file not detected. Generating it...
INFO  ==> Deploying PostgreSQL with persisted data...
INFO  ==> Configuring replication parameters
INFO  ==> Loading custom scripts...
INFO  ==> Enabling remote connections
INFO  ==> Stopping PostgreSQL...
INFO  ==> ** PostgreSQL setup finished! **

INFO  ==> ** Starting PostgreSQL **
  [1] FATAL:  database files are incompatible with server
  [1] DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.3.

In this case, you should migrate the data from the old chart to the new one following an approach similar to that described in this section from the official documentation. Basically, create a database dump in the old chart, move and restore it in the new one.

4.0.0

This chart will use by default the Bitnami PostgreSQL container starting from version 10.7.0-r68. This version moves the initialization logic from node.js to bash. This new version of the chart requires setting the POSTGRES_PASSWORD in the slaves as well, in order to properly configure the pg_hba.conf file. Users from previous versions of the chart are advised to upgrade immediately.

IMPORTANT: If you do not want to upgrade the chart version then make sure you use the 10.7.0-r68 version of the container. Otherwise, you will get this error

The POSTGRESQL_PASSWORD environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow the container to be started with blank passwords. This is recommended only for development

3.0.0

This releases make it possible to specify different nodeSelector, affinity and tolerations for master and slave pods. It also fixes an issue with postgresql.master.fullname helper template not obeying fullnameOverride.

Breaking changes

  • affinty has been renamed to master.affinity and slave.affinity.
  • tolerations has been renamed to master.tolerations and slave.tolerations.
  • nodeSelector has been renamed to master.nodeSelector and slave.nodeSelector.

2.0.0

In order to upgrade from the 0.X.X branch to 1.X.X, you should follow the below steps:

  • Obtain the service name (SERVICE_NAME) and password (OLD_PASSWORD) of the existing postgresql chart. You can find the instructions to obtain the password in the NOTES.txt, the service name can be obtained by running
console
$ kubectl get svc
  • Install (not upgrade) the new version
console
$ helm repo update
$ helm install my-release stable/postgresql
  • Connect to the new pod (you can obtain the name by running kubectl get pods):
console
$ kubectl exec -it NAME bash
  • Once logged in, create a dump file from the previous database using pg_dump, for that we should connect to the previous postgresql chart:
console
$ pg_dump -h SERVICE_NAME -U postgres DATABASE_NAME > /tmp/backup.sql

After run above command you should be prompted for a password, this password is the previous chart password (OLD_PASSWORD). This operation could take some time depending on the database size.

  • Once you have the backup file, you can restore it with a command like the one below:
console
$ psql -U postgres DATABASE_NAME < /tmp/backup.sql

In this case, you are accessing to the local postgresql, so the password should be the new one (you can find it in NOTES.txt).

If you want to restore the database and the database schema does not exist, it is necessary to first follow the steps described below.

console
$ psql -U postgres
postgres=# drop database DATABASE_NAME;
postgres=# create database DATABASE_NAME;
postgres=# create user USER_NAME;
postgres=# alter role USER_NAME with password 'BITNAMI_USER_PASSWORD';
postgres=# grant all privileges on database DATABASE_NAME to USER_NAME;
postgres=# alter database DATABASE_NAME owner to USER_NAME;