Changes: - update truncation to recommended practices - fix NOTES.txt for 1.5.x - fix newline in pvc
PostgreSQL
PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
TL;DR;
$ helm install stable/postgresql
Introduction
This chart bootstraps a PostgreSQL deployment on a Kubernetes cluster using the Helm package manager.
Prerequisites
- Kubernetes 1.4+ with Beta APIs enabled
- PV provisioner support in the underlying infrastructure (Only when persisting data)
Installing the Chart
To install the chart with the release name my-release:
$ helm install --name my-release stable/postgresql
The command deploys PostgreSQL on the Kubernetes cluster in the default configuration. The configuration 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:
$ helm delete my-release
The command removes all the Kubernetes components associated with the chart and deletes the release.
Configuration
The following tables lists the configurable parameters of the PostgresSQL chart and their default values.
| Parameter | Description | Default |
|---|---|---|
image |
postgres image repository |
postgres |
imageTag |
postgres image tag |
9.5.4 |
imagePullPolicy |
Image pull policy | Always if imageTag is latest, else IfNotPresent |
postgresUser |
Username of new user to create. | postgres |
postgresPassword |
Password for the new user. | random 10 characters |
postgresDatabase |
Name for new database to create. | postgres |
persistence.enabled |
Use a PVC to persist data | true |
persistence.storageClass |
Storage class of backing PVC | nil (uses alpha storage class annotation) |
persistence.accessMode |
Use volume as ReadOnly or ReadWrite | ReadWriteOnce |
persistence.size |
Size of data volume | 8Gi |
resources |
CPU/Memory resource requests/limits | Memory: 256Mi, CPU: 100m |
metrics.enabled |
Start a side-car prometheus exporter | false |
metrics.image |
Exporter image | wrouesnel/postgres_exporter |
metrics.imageTag |
Exporter image | v0.1.1 |
metrics.imagePullPolicy |
Exporter image pull policy | IfNotPresent |
metrics.resources |
Exporter resource requests/limit | Memory: 256Mi, CPU: 100m |
The above parameters map to the env variables defined in postgres. For more information please refer to the postgres image documentation.
Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,
$ helm install --name my-release \
--set postgresUser=my-user,postgresPassword=secretpassword,postgresDatabase=my-database \
stable/postgresql
The above command creates a PostgresSQL user named root with password 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,
$ helm install --name my-release -f values.yaml stable/postgresql
Tip
: You can use the default values.yaml
Persistence
The postgres image stores the PostgreSQL data and configurations at the /var/lib/postgresql/data/pgdata path of the container.
The chart mounts a Persistent Volume volume at this location. The volume is created using dynamic volume provisioning.
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.