|
| 1 | +# ⚠️ Repo Archive Notice |
| 2 | + |
| 3 | +As of Nov 13, 2020, charts in this repo will no longer be updated. |
| 4 | +For more information, see the Helm Charts [Deprecation and Archive Notice](https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice), and [Update](https://helm.sh/blog/charts-repo-deprecation/). |
| 5 | + |
| 6 | +# Patroni Helm Chart |
| 7 | + |
| 8 | +This directory contains a Kubernetes chart to deploy a five node [Patroni](https://github.com/zalando/patroni/) cluster using a [Spilo](https://github.com/zalando/spilo) and a StatefulSet. |
| 9 | + |
| 10 | + |
| 11 | +## Prerequisites Details |
| 12 | +* Kubernetes 1.9+ |
| 13 | +* PV support on the underlying infrastructure |
| 14 | + |
| 15 | +## StatefulSet Details |
| 16 | +* https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ |
| 17 | + |
| 18 | +## StatefulSet Caveats |
| 19 | +* https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#limitations |
| 20 | + |
| 21 | + |
| 22 | +## Chart Details |
| 23 | +This chart will do the following: |
| 24 | + |
| 25 | +* Implement a HA scalable PostgreSQL 10 cluster using a Kubernetes StatefulSet. |
| 26 | + |
| 27 | +## Installing the Chart |
| 28 | + |
| 29 | +To install the chart with the release name `my-release`: |
| 30 | + |
| 31 | +```console |
| 32 | +$ helm repo add |
| 33 | +$ helm dependency update |
| 34 | +$ helm install --name my-release postgresql-cluster |
| 35 | +``` |
| 36 | + |
| 37 | +To install the chart with randomly generated passwords: |
| 38 | + |
| 39 | +```console |
| 40 | +$ helm install --name my-release postgresql-cluster \ |
| 41 | + --set credentials.superuser="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)",credentials.admin="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)",credentials.standby="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)" |
| 42 | +``` |
| 43 | + |
| 44 | +## Connecting to PostgreSQL |
| 45 | + |
| 46 | +Your access point is a cluster IP. In order to access it spin up another pod: |
| 47 | + |
| 48 | +```console |
| 49 | +$ kubectl run -i --tty --rm psql --image=postgres --restart=Never -- bash -il |
| 50 | +``` |
| 51 | + |
| 52 | +Then, from inside the pod, connect to PostgreSQL: |
| 53 | + |
| 54 | +```console |
| 55 | +$ psql -U admin -h my-release-patroni.default.svc.cluster.local postgres |
| 56 | +<admin password from values.yaml> |
| 57 | +postgres=> |
| 58 | +``` |
| 59 | + |
| 60 | +## Configuration |
| 61 | + |
| 62 | +The following table lists the configurable parameters of the patroni chart and their default values. |
| 63 | + |
| 64 | +| Parameter | Description | Default | |
| 65 | +|-----------------------------------|---------------------------------------------|-----------------------------------------------------| |
| 66 | +| `nameOverride` | Override the name of the chart | `nil` | |
| 67 | +| `fullnameOverride` | Override the fullname of the chart | `nil` | |
| 68 | +| `replicaCount` | Amount of pods to spawn | `5` | |
| 69 | +| `image.repository` | The image to pull | `registry.opensource.zalan.do/acid/spilo-10` | |
| 70 | +| `image.tag` | The version of the image to pull | `1.5-p5` | |
| 71 | +| `image.pullPolicy` | The pull policy | `IfNotPresent` | |
| 72 | +| `credentials.superuser` | Password of the superuser | `tea` | |
| 73 | +| `credentials.admin` | Password of the admin | `cola` | |
| 74 | +| `credentials.standby` | Password of the replication user | `pinacolada` | |
| 75 | +| `kubernetes.dcs.enable` | Using Kubernetes as DCS | `true` | |
| 76 | +| `kubernetes.configmaps.enable` | Using Kubernetes configmaps instead of endpoints | `false` | |
| 77 | +| `etcd.enable` | Using etcd as DCS | `false` | |
| 78 | +| `etcd.deployChart` | Deploy etcd chart | `false` | |
| 79 | +| `etcd.host` | Host name of etcd cluster | `nil` | |
| 80 | +| `etcd.discovery` | Domain name of etcd cluster | `nil` | |
| 81 | +| `zookeeper.enable` | Using ZooKeeper as DCS | `false` | |
| 82 | +| `zookeeper.deployChart` | Deploy ZooKeeper chart | `false` | |
| 83 | +| `zookeeper.hosts` | List of ZooKeeper cluster members | `host1:port1,host2:port,etc...` | |
| 84 | +| `consul.enable` | Using Consul as DCS | `false` | |
| 85 | +| `consul.deployChart` | Deploy Consul chart | `false` | |
| 86 | +| `consul.host` | Host name of consul cluster | `nil` | |
| 87 | +| `env` | Extra custom environment variables | `{}` | |
| 88 | +| `walE.enable` | Use of Wal-E tool for base backup/restore | `false` | |
| 89 | +| `walE.scheduleCronJob` | Schedule of Wal-E backups | `00 01 * * *` | |
| 90 | +| `walE.retainBackups` | Number of base backups to retain | `2` | |
| 91 | +| `walE.s3Bucket:` | Amazon S3 bucket used for wal-e backups | `nil` | |
| 92 | +| `walE.gcsBucket` | GCS storage used for Wal-E backups | `nil` | |
| 93 | +| `walE.kubernetesSecret` | K8s secret name for provider bucket | `nil` | |
| 94 | +| `walE.backupThresholdMegabytes` | Maximum size of the WAL segments accumulated after the base backup to consider WAL-E restore instead of pg_basebackup | `1024` | |
| 95 | +| `walE.backupThresholdPercentage` | Maximum ratio (in percents) of the accumulated WAL files to the base backup to consider WAL-E restore instead of pg_basebackup | `30` | |
| 96 | +| `resources` | Any resources you wish to assign to the pod | `{}` | |
| 97 | +| `nodeSelector` | Node label to use for scheduling | `{}` | |
| 98 | +| `tolerations` | List of node taints to tolerate | `[]` | |
| 99 | +| `affinityTemplate` | A template string to use to generate the affinity settings | Anti-affinity preferred on hostname | |
| 100 | +| `affinity` | Affinity settings. Overrides `affinityTemplate` if set. | `{}` | |
| 101 | +| `schedulerName` | Alternate scheduler name | `nil` | |
| 102 | +| `persistentVolume.accessModes` | Persistent Volume access modes | `[ReadWriteOnce]` | |
| 103 | +| `persistentVolume.annotations` | Annotations for Persistent Volume Claim` | `{}` | |
| 104 | +| `persistentVolume.mountPath` | Persistent Volume mount root path | `/home/postgres/pgdata` | |
| 105 | +| `persistentVolume.size` | Persistent Volume size | `2Gi` | |
| 106 | +| `persistentVolume.storageClass` | Persistent Volume Storage Class | `volume.alpha.kubernetes.io/storage-class: default` | |
| 107 | +| `persistentVolume.subPath` | Subdirectory of Persistent Volume to mount | `""` | |
| 108 | +| `rbac.create` | Create required role and rolebindings | `true` | |
| 109 | +| `serviceAccount.create` | If true, create a new service account | `true` | |
| 110 | +| `serviceAccount.name` | Service account to be used. If not set and `serviceAccount.create` is `true`, a name is generated using the fullname template | `nil` | |
| 111 | + |
| 112 | +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. |
| 113 | + |
| 114 | +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, |
| 115 | + |
| 116 | +```console |
| 117 | +$ helm install --name my-release -f values.yaml incubator/patroni |
| 118 | +``` |
| 119 | + |
| 120 | +> **Tip**: You can use the default [values.yaml](values.yaml) |
| 121 | +
|
| 122 | +## Cleanup |
| 123 | + |
| 124 | +To remove the spawned pods you can run a simple `helm delete <release-name>`. |
| 125 | + |
| 126 | +Helm will however preserve created persistent volume claims, |
| 127 | +to also remove them execute the commands below. |
| 128 | + |
| 129 | +```console |
| 130 | +$ release=<release-name> |
| 131 | +$ helm delete $release |
| 132 | +$ kubectl delete pvc -l release=$release |
| 133 | +``` |
| 134 | + |
| 135 | +## Internals |
| 136 | + |
| 137 | +Patroni is responsible for electing a PostgreSQL master pod by leveraging the |
| 138 | +DCS of your choice. After election it adds a `spilo-role=master` label to the |
| 139 | +elected master and set the label to `spilo-role=replica` for all replicas. |
| 140 | +Simultaneously it will update the `<release-name>-patroni` endpoint to let the |
| 141 | +service route traffic to the elected master. |
| 142 | + |
| 143 | +```console |
| 144 | +$ kubectl get pods -l spilo-role -L spilo-role |
| 145 | +NAME READY STATUS RESTARTS AGE SPILO-ROLE |
| 146 | +my-release-patroni-0 1/1 Running 0 9m replica |
| 147 | +my-release-patroni-1 1/1 Running 0 9m master |
| 148 | +my-release-patroni-2 1/1 Running 0 8m replica |
| 149 | +my-release-patroni-3 1/1 Running 0 8m replica |
| 150 | +my-release-patroni-4 1/1 Running 0 8m replica |
| 151 | +``` |
0 commit comments