3 [PostgreSQL](https://www.postgresql.org/) is an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance.
5 For HA, please see [this repo](https://github.com/bitnami/charts/tree/master/bitnami/postgresql-ha)
10 $ helm install stable/postgresql
15 This chart bootstraps a [PostgreSQL](https://github.com/bitnami/bitnami-docker-postgresql) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
17 Bitnami charts can be used with [Kubeapps](https://kubeapps.com/) 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](https://kubeprod.io/).
22 - Helm 2.11+ or Helm 3.0-beta3+
23 - PV provisioner support in the underlying infrastructure
25 ## Installing the Chart
26 To install the chart with the release name `my-release`:
29 $ helm install --name my-release stable/postgresql
32 The command deploys PostgreSQL on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.
34 > **Tip**: List all releases using `helm list`
36 ## Uninstalling the Chart
38 To uninstall/delete the `my-release` deployment:
41 $ helm delete my-release
44 The command removes all the Kubernetes components associated with the chart and deletes the release.
48 The following tables lists the configurable parameters of the PostgreSQL chart and their default values.
50 | Parameter | Description | Default |
51 |-----------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
52 | `global.imageRegistry` | Global Docker Image registry | `nil` |
53 | `global.postgresql.postgresqlDatabase` | PostgreSQL database (overrides `postgresqlDatabase`) | `nil` |
54 | `global.postgresql.postgresqlUsername` | PostgreSQL username (overrides `postgresqlUsername`) | `nil` |
55 | `global.postgresql.existingSecret` | Name of existing secret to use for PostgreSQL passwords (overrides `existingSecret`) | `nil` |
56 | `global.postgresql.postgresqlPassword` | PostgreSQL admin password (overrides `postgresqlPassword`) | `nil` |
57 | `global.postgresql.servicePort` | PostgreSQL port (overrides `service.port`) | `nil` |
58 | `global.postgresql.replicationPassword` | Replication user password (overrides `replication.password`) | `nil` |
59 | `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
60 | `global.storageClass` | Global storage class for dynamic provisioning | `nil` |
61 | `image.registry` | PostgreSQL Image registry | `docker.io` |
62 | `image.repository` | PostgreSQL Image name | `bitnami/postgresql` |
63 | `image.tag` | PostgreSQL Image tag | `{TAG_NAME}` |
64 | `image.pullPolicy` | PostgreSQL Image pull policy | `IfNotPresent` |
65 | `image.pullSecrets` | Specify Image pull secrets | `nil` (does not add image pull secrets to deployed pods) |
66 | `image.debug` | Specify if debug values should be set | `false` |
67 | `nameOverride` | String to partially override postgresql.fullname template with a string (will prepend the release name) | `nil` |
68 | `fullnameOverride` | String to fully override postgresql.fullname template with a string | `nil` |
69 | `volumePermissions.image.registry` | Init container volume-permissions image registry | `docker.io` |
70 | `volumePermissions.image.repository` | Init container volume-permissions image name | `bitnami/minideb` |
71 | `volumePermissions.image.tag` | Init container volume-permissions image tag | `stretch` |
72 | `volumePermissions.image.pullPolicy` | Init container volume-permissions image pull policy | `Always` |
73 | `volumePermissions.securityContext.runAsUser` | User ID for the init container | `0` |
74 | `usePasswordFile` | Have the secrets mounted as a file instead of env vars | `false` |
75 | `ldap.enabled` | Enable LDAP support | `false` |
76 | `ldap.existingSecret` | Name of existing secret to use for LDAP passwords | `nil` |
77 | `ldap.url` | LDAP URL beginning in the form `ldap[s]://host[:port]/basedn[?[attribute][?[scope][?[filter]]]]` | `nil` |
78 | `ldap.server` | IP address or name of the LDAP server. | `nil` |
79 | `ldap.port` | Port number on the LDAP server to connect to | `nil` |
80 | `ldap.scheme` | Set to `ldaps` to use LDAPS. | `nil` |
81 | `ldap.tls` | Set to `1` to use TLS encryption | `nil` |
82 | `ldap.prefix` | String to prepend to the user name when forming the DN to bind | `nil` |
83 | `ldap.suffix` | String to append to the user name when forming the DN to bind | `nil` |
84 | `ldap.search_attr` | Attribute to match agains the user name in the search | `nil` |
85 | `ldap.search_filter` | The search filter to use when doing search+bind authentication | `nil` |
86 | `ldap.baseDN` | Root DN to begin the search for the user in | `nil` |
87 | `ldap.bindDN` | DN of user to bind to LDAP | `nil` |
88 | `ldap.bind_password` | Password for the user to bind to LDAP | `nil` |
89 | `replication.enabled` | Enable replication | `false` |
90 | `replication.user` | Replication user | `repl_user` |
91 | `replication.password` | Replication user password | `repl_password` |
92 | `replication.slaveReplicas` | Number of slaves replicas | `1` |
93 | `replication.synchronousCommit` | Set synchronous commit mode. Allowed values: `on`, `remote_apply`, `remote_write`, `local` and `off` | `off` |
94 | `replication.numSynchronousReplicas` | Number of replicas that will have synchronous replication. Note: Cannot be greater than `replication.slaveReplicas`. | `0` |
95 | `replication.applicationName` | Cluster application name. Useful for advanced replication settings | `my_application` |
96 | `existingSecret` | Name of existing secret to use for PostgreSQL passwords | `nil` |
97 | `postgresqlPostgresPassword` | PostgreSQL admin password (used when `postgresqlUsername` is not `postgres`) | _random 10 character alphanumeric string_ |
98 | `postgresqlUsername` | PostgreSQL admin user | `postgres` |
99 | `postgresqlPassword` | PostgreSQL admin password | _random 10 character alphanumeric string_ |
100 | `postgresqlDatabase` | PostgreSQL database | `nil` |
101 | `postgresqlDataDir` | PostgreSQL data dir folder | `/bitnami/postgresql` (same value as persistence.mountPath) |
102 | `extraEnv` | Any extra environment variables you would like to pass on to the pod. The value is evaluated as a template. | `[]` |
103 | `postgresqlInitdbArgs` | PostgreSQL initdb extra arguments | `nil` |
104 | `postgresqlInitdbWalDir` | PostgreSQL location for transaction log | `nil` |
105 | `postgresqlConfiguration` | Runtime Config Parameters | `nil` |
106 | `postgresqlExtendedConf` | Extended Runtime Config Parameters (appended to main or default configuration) | `nil` |
107 | `pgHbaConfiguration` | Content of pg_hba.conf | `nil (do not create pg_hba.conf)` |
108 | `configurationConfigMap` | ConfigMap with the PostgreSQL configuration files (Note: Overrides `postgresqlConfiguration` and `pgHbaConfiguration`). The value is evaluated as a template. | `nil` |
109 | `extendedConfConfigMap` | ConfigMap with the extended PostgreSQL configuration files. The value is evaluated as a template. | `nil` |
110 | `initdbScripts` | Dictionary of initdb scripts | `nil` |
111 | `initdbUsername` | PostgreSQL user to execute the .sql and sql.gz scripts | `nil` |
112 | `initdbPassword` | Password for the user specified in `initdbUsername` | `nil` |
113 | `initdbScriptsConfigMap` | ConfigMap with the initdb scripts (Note: Overrides `initdbScripts`). The value is evaluated as a template. | `nil` |
114 | `initdbScriptsSecret` | Secret with initdb scripts that contain sensitive information (Note: can be used with `initdbScriptsConfigMap` or `initdbScripts`). The value is evaluated as a template. | `nil` |
115 | `service.type` | Kubernetes Service type | `ClusterIP` |
116 | `service.port` | PostgreSQL port | `5432` |
117 | `service.nodePort` | Kubernetes Service nodePort | `nil` |
118 | `service.annotations` | Annotations for PostgreSQL service, the value is evaluated as a template. | {} |
119 | `service.loadBalancerIP` | loadBalancerIP if service type is `LoadBalancer` | `nil` |
120 | `service.loadBalancerSourceRanges` | Address that are allowed when svc is LoadBalancer | [] |
121 | `schedulerName` | Name of the k8s scheduler (other than default) | `nil` |
122 | `shmVolume.enabled` | Enable emptyDir volume for /dev/shm for master and slave(s) Pod(s) | `true` |
123 | `persistence.enabled` | Enable persistence using PVC | `true` |
124 | `persistence.existingClaim` | Provide an existing `PersistentVolumeClaim`, the value is evaluated as a template. | `nil` |
125 | `persistence.mountPath` | Path to mount the volume at | `/bitnami/postgresql` |
126 | `persistence.subPath` | Subdirectory of the volume to mount at | `""` |
127 | `persistence.storageClass` | PVC Storage Class for PostgreSQL volume | `nil` |
128 | `persistence.accessModes` | PVC Access Mode for PostgreSQL volume | `[ReadWriteOnce]` |
129 | `persistence.size` | PVC Storage Request for PostgreSQL volume | `8Gi` |
130 | `persistence.annotations` | Annotations for the PVC | `{}` |
131 | `master.nodeSelector` | Node labels for pod assignment (postgresql master) | `{}` |
132 | `master.affinity` | Affinity labels for pod assignment (postgresql master) | `{}` |
133 | `master.tolerations` | Toleration labels for pod assignment (postgresql master) | `[]` |
134 | `master.anotations` | Map of annotations to add to the statefulset (postgresql master) | `{}` |
135 | `master.labels` | Map of labels to add to the statefulset (postgresql master) | `{}` |
136 | `master.podAnnotations` | Map of annotations to add to the pods (postgresql master) | `{}` |
137 | `master.podLabels` | Map of labels to add to the pods (postgresql master) | `{}` |
138 | `master.priorityClassName` | Priority Class to use for each pod (postgresql master) | `nil` |
139 | `master.extraInitContainers` | Additional init containers to add to the pods (postgresql master) | `[]` |
140 | `master.extraVolumeMounts` | Additional volume mounts to add to the pods (postgresql master) | `[]` |
141 | `master.extraVolumes` | Additional volumes to add to the pods (postgresql master) | `[]` |
142 | `slave.nodeSelector` | Node labels for pod assignment (postgresql slave) | `{}` |
143 | `slave.affinity` | Affinity labels for pod assignment (postgresql slave) | `{}` |
144 | `slave.tolerations` | Toleration labels for pod assignment (postgresql slave) | `[]` |
145 | `slave.anotations` | Map of annotations to add to the statefulsets (postgresql slave) | `{}` |
146 | `slave.labels` | Map of labels to add to the statefulsets (postgresql slave) | `{}` |
147 | `slave.podAnnotations` | Map of annotations to add to the pods (postgresql slave) | `{}` |
148 | `slave.podLabels` | Map of labels to add to the pods (postgresql slave) | `{}` |
149 | `slave.priorityClassName` | Priority Class to use for each pod (postgresql slave) | `nil` |
150 | `slave.extraInitContainers` | Additional init containers to add to the pods (postgresql slave) | `[]` |
151 | `slave.extraVolumeMounts` | Additional volume mounts to add to the pods (postgresql slave) | `[]` |
152 | `slave.extraVolumes` | Additional volumes to add to the pods (postgresql slave) | `[]` |
153 | `terminationGracePeriodSeconds` | Seconds the pod needs to terminate gracefully | `nil` |
154 | `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `250m` |
155 | `securityContext.enabled` | Enable security context | `true` |
156 | `securityContext.fsGroup` | Group ID for the container | `1001` |
157 | `securityContext.runAsUser` | User ID for the container | `1001` |
158 | `serviceAccount.enabled` | Enable service account (Note: Service Account will only be automatically created if `serviceAccount.name` is not set) | `false` |
159 | `serviceAcccount.name` | Name of existing service account | `nil` |
160 | `livenessProbe.enabled` | Would you like a livenessProbe to be enabled | `true` |
161 | `networkPolicy.enabled` | Enable NetworkPolicy | `false` |
162 | `networkPolicy.allowExternal` | Don't require client label for connections | `true` |
163 | `networkPolicy.explicitNamespacesSelector` | A Kubernetes LabelSelector to explicitly select namespaces from which ingress traffic could be allowed | `nil` |
164 | `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 |
165 | `livenessProbe.periodSeconds` | How often to perform the probe | 10 |
166 | `livenessProbe.timeoutSeconds` | When the probe times out | 5 |
167 | `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 6 |
168 | `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
169 | `readinessProbe.enabled` | would you like a readinessProbe to be enabled | `true` |
170 | `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | 5 |
171 | `readinessProbe.periodSeconds` | How often to perform the probe | 10 |
172 | `readinessProbe.timeoutSeconds` | When the probe times out | 5 |
173 | `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 6 |
174 | `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
175 | `metrics.enabled` | Start a prometheus exporter | `false` |
176 | `metrics.service.type` | Kubernetes Service type | `ClusterIP` |
177 | `service.clusterIP` | Static clusterIP or None for headless services | `nil` |
178 | `metrics.service.annotations` | Additional annotations for metrics exporter pod | `{ prometheus.io/scrape: "true", prometheus.io/port: "9187"}` |
179 | `metrics.service.loadBalancerIP` | loadBalancerIP if redis metrics service type is `LoadBalancer` | `nil` |
180 | `metrics.serviceMonitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` |
181 | `metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}` |
182 | `metrics.serviceMonitor.namespace` | Optional namespace in which to create ServiceMonitor | `nil` |
183 | `metrics.serviceMonitor.interval` | Scrape interval. If not set, the Prometheus default scrape interval is used | `nil` |
184 | `metrics.serviceMonitor.scrapeTimeout` | Scrape timeout. If not set, the Prometheus default scrape timeout is used | `nil` |
185 | `metrics.prometheusRule.enabled` | Set this to true to create prometheusRules for Prometheus operator | `false` |
186 | `metrics.prometheusRule.additionalLabels` | Additional labels that can be used so prometheusRules will be discovered by Prometheus | `{}` |
187 | `metrics.prometheusRule.namespace` | namespace where prometheusRules resource should be created | the same namespace as postgresql |
188 | `metrics.prometheusRule.rules` | [rules](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/) to be created, check values for an example. | `[]` |
189 | `metrics.image.registry` | PostgreSQL Image registry | `docker.io` |
190 | `metrics.image.repository` | PostgreSQL Image name | `bitnami/postgres-exporter` |
191 | `metrics.image.tag` | PostgreSQL Image tag | `{TAG_NAME}` |
192 | `metrics.image.pullPolicy` | PostgreSQL Image pull policy | `IfNotPresent` |
193 | `metrics.image.pullSecrets` | Specify Image pull secrets | `nil` (does not add image pull secrets to deployed pods) |
194 | `metrics.customMetrics` | Additional custom metrics | `nil` |
195 | `metrics.securityContext.enabled` | Enable security context for metrics | `false` |
196 | `metrics.securityContext.runAsUser` | User ID for the container for metrics | `1001` |
197 | `metrics.livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 |
198 | `metrics.livenessProbe.periodSeconds` | How often to perform the probe | 10 |
199 | `metrics.livenessProbe.timeoutSeconds` | When the probe times out | 5 |
200 | `metrics.livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 6 |
201 | `metrics.livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
202 | `metrics.readinessProbe.enabled` | would you like a readinessProbe to be enabled | `true` |
203 | `metrics.readinessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 5 |
204 | `metrics.readinessProbe.periodSeconds` | How often to perform the probe | 10 |
205 | `metrics.readinessProbe.timeoutSeconds` | When the probe times out | 5 |
206 | `metrics.readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 6 |
207 | `metrics.readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
208 | `updateStrategy` | Update strategy policy | `{type: "RollingUpdate"}` |
210 Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
213 $ helm install --name my-release \
214 --set postgresqlPassword=secretpassword,postgresqlDatabase=my-database \
218 The above command sets the PostgreSQL `postgres` account password to `secretpassword`. Additionally it creates a database named `my-database`.
220 Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
223 $ helm install --name my-release -f values.yaml stable/postgresql
226 > **Tip**: You can use the default [values.yaml](values.yaml)
228 ## Configuration and installation details
230 ### [Rolling VS Immutable tags](https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/)
232 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.
234 Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.
236 ### Production configuration and horizontal scaling
238 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.
240 - Enable replication:
242 - replication.enabled: false
243 + replication.enabled: true
246 - Number of slaves replicas:
248 - replication.slaveReplicas: 1
249 + replication.slaveReplicas: 2
252 - Set synchronous commit mode:
254 - replication.synchronousCommit: "off"
255 + replication.synchronousCommit: "on"
258 - Number of replicas that will have synchronous replication:
260 - replication.numSynchronousReplicas: 0
261 + replication.numSynchronousReplicas: 1
264 - Start a prometheus exporter:
266 - metrics.enabled: false
267 + metrics.enabled: true
270 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.
272 ### Change PostgreSQL version
274 To modify the PostgreSQL version used in this chart you can specify a [valid image tag](https://hub.docker.com/r/bitnami/postgresql/tags/) using the `image.tag` parameter. For example, `image.tag=12.0.0-debian-9-r0`
276 ### postgresql.conf / pg_hba.conf files as configMap
278 This helm chart also supports to customize the whole configuration file.
280 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.
282 Alternatively, you can specify PostgreSQL configuration parameters using the `postgresqlConfiguration` parameter as a dict, using camelCase, e.g. {"sharedBuffers": "500MB"}.
284 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.
286 ### Allow settings to be loaded from files other than the default `postgresql.conf`
288 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.
289 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`.
291 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.
293 ### Initialize a fresh instance
295 The [Bitnami PostgreSQL](https://github.com/bitnami/bitnami-docker-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.
297 Alternatively, you can specify custom scripts using the `initdbScripts` parameter as dict.
299 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.
301 The allowed extensions are `.sh`, `.sql` and `.sql.gz`.
305 The chart optionally can start a metrics exporter for [prometheus](https://prometheus.io). 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](https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml).
307 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](https://github.com/wrouesnel/postgres_exporter#adding-new-metrics-via-a-config-file) for more details.
309 ### Use of global variables
311 In more complex scenarios, we may have the following tree of dependencies
316 +------------+ Chart 1 +-----------+
324 +-------+------+ +--------+------+ +--------+------+
326 | PostgreSQL | | Sub-chart 1 | | Sub-chart 2 |
328 +--------------+ +---------------+ +---------------+
331 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:
334 postgresql.postgresqlPassword=testtest
335 subchart1.postgresql.postgresqlPassword=testtest
336 subchart2.postgresql.postgresqlPassword=testtest
337 postgresql.postgresqlDatabase=db1
338 subchart1.postgresql.postgresqlDatabase=db1
339 subchart2.postgresql.postgresqlDatabase=db1
342 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:
345 global.postgresql.postgresqlPassword=testtest
346 global.postgresql.postgresqlDatabase=db1
349 This way, the credentials will be available in all of the subcharts.
353 The [Bitnami PostgreSQL](https://github.com/bitnami/bitnami-docker-postgresql) image stores the PostgreSQL data and configurations at the `/bitnami/postgresql` path of the container.
355 Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube.
356 See the [Parameters](#parameters) section to configure the PVC or to disable persistence.
358 If you already have data in it, you will fail to sync to standby nodes for all commits, details can refer to [code](https://github.com/bitnami/bitnami-docker-postgresql/blob/8725fe1d7d30ebe8d9a16e9175d05f7ad9260c93/9.6/debian-9/rootfs/libpostgresql.sh#L518-L556). If you need to use those data, please covert them to sql and import after `helm install` finished.
362 To enable network policy for PostgreSQL, install [a networking plugin that implements the Kubernetes NetworkPolicy spec](https://kubernetes.io/docs/tasks/administer-cluster/declare-network-policy#before-you-begin), and set `networkPolicy.enabled` to `true`.
364 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:
367 $ kubectl annotate namespace default "net.beta.kubernetes.io/network-policy={\"ingress\":{\"isolation\":\"DefaultDeny\"}}"
370 With NetworkPolicy enabled, traffic will be limited to just port 5432.
372 For more precise policy, set `networkPolicy.allowExternal=false`. This will only allow pods with the generated client label to connect to PostgreSQL.
373 This label will be displayed in the output of a successful install.
375 ## Differences between Bitnami PostgreSQL image and [Docker Official](https://hub.docker.com/_/postgres) image
377 - 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.
378 - 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.
380 ### Deploy chart using Docker Official PostgreSQL Image
382 From chart version 4.0.0, it is possible to use this chart with the Docker Official PostgreSQL image.
383 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.
386 helm install --name postgres \
387 --set image.repository=postgres \
388 --set image.tag=10.6 \
389 --set postgresqlDataDir=/data/pgdata \
390 --set persistence.mountPath=/data/ \
396 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:
399 $ helm upgrade my-release bitnami/influxdb \
400 --set postgresqlPassword=[POSTGRESQL_PASSWORD] \
401 --set replication.password=[REPLICATION_PASSWORD]
404 > Note: you need to substitute the placeholders _[POSTGRESQL_PASSWORD]_, and _[REPLICATION_PASSWORD]_ with the values obtained from instructions in the installation notes.
408 Prefixes the port names with their protocols to comply with Istio conventions.
410 If you depend on the port names in your setup, make sure to update them to reflect this change.
414 Adds support for LDAP configuration.
418 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.
420 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.
422 This major version bump signifies this change.
426 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:
436 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/](https://www.postgresql.org/about/news/1894/) and [https://www.postgresql.org/about/featurematrix/](https://www.postgresql.org/about/featurematrix/).
438 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:
441 Welcome to the Bitnami postgresql container
442 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
443 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
444 Send us your feedback at containers@bitnami.com
446 INFO ==> ** Starting PostgreSQL setup **
447 NFO ==> Validating settings in POSTGRESQL_* env vars..
448 INFO ==> Initializing PostgreSQL database...
449 INFO ==> postgresql.conf file not detected. Generating it...
450 INFO ==> pg_hba.conf file not detected. Generating it...
451 INFO ==> Deploying PostgreSQL with persisted data...
452 INFO ==> Configuring replication parameters
453 INFO ==> Loading custom scripts...
454 INFO ==> Enabling remote connections
455 INFO ==> Stopping PostgreSQL...
456 INFO ==> ** PostgreSQL setup finished! **
458 INFO ==> ** Starting PostgreSQL **
459 [1] FATAL: database files are incompatible with server
460 [1] DETAIL: The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.3.
462 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](https://www.postgresql.org/docs/current/upgrading.html#UPGRADING-VIA-PGDUMPALL) from the official documentation. Basically, create a database dump in the old chart, move and restore it in the new one.
466 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.
468 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
471 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
476 This releases make it possible to specify different nodeSelector, affinity and tolerations for master and slave pods.
477 It also fixes an issue with `postgresql.master.fullname` helper template not obeying fullnameOverride.
479 #### Breaking changes
481 - `affinty` has been renamed to `master.affinity` and `slave.affinity`.
482 - `tolerations` has been renamed to `master.tolerations` and `slave.tolerations`.
483 - `nodeSelector` has been renamed to `master.nodeSelector` and `slave.nodeSelector`.
487 In order to upgrade from the `0.X.X` branch to `1.X.X`, you should follow the below steps:
489 - 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
495 - Install (not upgrade) the new version
499 $ helm install --name my-release stable/postgresql
502 - Connect to the new pod (you can obtain the name by running `kubectl get pods`):
505 $ kubectl exec -it NAME bash
508 - Once logged in, create a dump file from the previous database using `pg_dump`, for that we should connect to the previous postgresql chart:
511 $ pg_dump -h SERVICE_NAME -U postgres DATABASE_NAME > /tmp/backup.sql
514 After run above command you should be prompted for a password, this password is the previous chart password (`OLD_PASSWORD`).
515 This operation could take some time depending on the database size.
517 - Once you have the backup file, you can restore it with a command like the one below:
520 $ psql -U postgres DATABASE_NAME < /tmp/backup.sql
523 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).
525 If you want to restore the database and the database schema does not exist, it is necessary to first follow the steps described below.
529 postgres=# drop database DATABASE_NAME;
530 postgres=# create database DATABASE_NAME;
531 postgres=# create user USER_NAME;
532 postgres=# alter role USER_NAME with password 'BITNAMI_USER_PASSWORD';
533 postgres=# grant all privileges on database DATABASE_NAME to USER_NAME;
534 postgres=# alter database DATABASE_NAME owner to USER_NAME;