|
3 | 3 | Learn how to configure and manage the Postgres Operator in your Kubernetes (K8s) |
4 | 4 | environment. |
5 | 5 |
|
| 6 | +## Upgrading the operator |
| 7 | + |
| 8 | +The Postgres Operator is upgraded by changing the docker image within the |
| 9 | +deployment. Before doing so, it is recommended to check the release notes |
| 10 | +for new configuration options or changed behavior you might want to reflect |
| 11 | +in the ConfigMap or config CRD. E.g. a new feature might get introduced which |
| 12 | +is enabled or disabled by default and you want to change it to the opposite |
| 13 | +with the corresponding flag option. |
| 14 | + |
| 15 | +When using helm, be aware that installing the new chart will not update the |
| 16 | +`Postgresql` and `OperatorConfiguration` CRD. Make sure to update them before |
| 17 | +with the provided manifests in the `crds` folder. Otherwise, you might face |
| 18 | +errors about new Postgres manifest or configuration options being unknown |
| 19 | +to the CRD schema validation. |
| 20 | + |
6 | 21 | ## Minor and major version upgrade |
7 | 22 |
|
8 | 23 | Minor version upgrades for PostgreSQL are handled via updating the Spilo Docker |
@@ -157,20 +172,26 @@ from numerous escape characters in the latter log entry, view it in CLI with |
157 | 172 | `PodTemplate` used by the operator is yet to be updated with the default values |
158 | 173 | used internally in K8s. |
159 | 174 |
|
160 | | -The operator also support lazy updates of the Spilo image. That means the pod |
161 | | -template of a PG cluster's stateful set is updated immediately with the new |
162 | | -image, but no rolling update follows. This feature saves you a switchover - and |
163 | | -hence downtime - when you know pods are re-started later anyway, for instance |
164 | | -due to the node rotation. To force a rolling update, disable this mode by |
165 | | -setting the `enable_lazy_spilo_upgrade` to `false` in the operator configuration |
166 | | -and restart the operator pod. With the standard eager rolling updates the |
167 | | -operator checks during Sync all pods run images specified in their respective |
168 | | -statefulsets. The operator triggers a rolling upgrade for PG clusters that |
169 | | -violate this condition. |
170 | | - |
171 | | -Changes in $SPILO\_CONFIGURATION under path bootstrap.dcs are ignored when |
172 | | -StatefulSets are being compared, if there are changes under this path, they are |
173 | | -applied through rest api interface and following restart of patroni instance |
| 175 | +The StatefulSet is replaced if the following properties change: |
| 176 | +- annotations |
| 177 | +- volumeClaimTemplates |
| 178 | +- template volumes |
| 179 | + |
| 180 | +The StatefulSet is replaced and a rolling updates is triggered if the following |
| 181 | +properties differ between the old and new state: |
| 182 | +- container name, ports, image, resources, env, envFrom, securityContext and volumeMounts |
| 183 | +- template labels, annotations, service account, securityContext, affinity, priority class and termination grace period |
| 184 | + |
| 185 | +Note that, changes in `SPILO_CONFIGURATION` env variable under `bootstrap.dcs` |
| 186 | +path are ignored for the diff. They will be applied through Patroni's rest api |
| 187 | +interface, following a restart of all instances. |
| 188 | + |
| 189 | +The operator also support lazy updates of the Spilo image. In this case the |
| 190 | +StatefulSet is only updated, but no rolling update follows. This feature saves |
| 191 | +you a switchover - and hence downtime - when you know pods are re-started later |
| 192 | +anyway, for instance due to the node rotation. To force a rolling update, |
| 193 | +disable this mode by setting the `enable_lazy_spilo_upgrade` to `false` in the |
| 194 | +operator configuration and restart the operator pod. |
174 | 195 |
|
175 | 196 | ## Delete protection via annotations |
176 | 197 |
|
@@ -667,6 +688,12 @@ if it ends up in your specified WAL backup path: |
667 | 688 | envdir "/run/etc/wal-e.d/env" /scripts/postgres_backup.sh "/home/postgres/pgdata/pgroot/data" |
668 | 689 | ``` |
669 | 690 |
|
| 691 | +You can also check if Spilo is able to find any backups: |
| 692 | + |
| 693 | +```bash |
| 694 | +envdir "/run/etc/wal-e.d/env" wal-g backup-list |
| 695 | +``` |
| 696 | + |
670 | 697 | Depending on the cloud storage provider different [environment variables](https://github.com/zalando/spilo/blob/master/ENVIRONMENT.rst) |
671 | 698 | have to be set for Spilo. Not all of them are generated automatically by the |
672 | 699 | operator by changing its configuration. In this case you have to use an |
@@ -734,8 +761,15 @@ WALE_S3_ENDPOINT='https+path://s3.eu-central-1.amazonaws.com:443' |
734 | 761 | WALE_S3_PREFIX=$WAL_S3_BUCKET/spilo/{WAL_BUCKET_SCOPE_PREFIX}{SCOPE}{WAL_BUCKET_SCOPE_SUFFIX}/wal/{PGVERSION} |
735 | 762 | ``` |
736 | 763 |
|
737 | | -If the prefix is not specified Spilo will generate it from `WAL_S3_BUCKET`. |
738 | | -When the `AWS_REGION` is set `AWS_ENDPOINT` and `WALE_S3_ENDPOINT` are |
| 764 | +The operator sets the prefix to an empty string so that spilo will generate it |
| 765 | +from the configured `WAL_S3_BUCKET`. |
| 766 | + |
| 767 | +:warning: When you overwrite the configuration by defining `WAL_S3_BUCKET` in |
| 768 | +the [pod_environment_configmap](#custom-pod-environment-variables) you have |
| 769 | +to set `WAL_BUCKET_SCOPE_PREFIX = ""`, too. Otherwise Spilo will not find |
| 770 | +the physical backups on restore (next chapter). |
| 771 | + |
| 772 | +When the `AWS_REGION` is set, `AWS_ENDPOINT` and `WALE_S3_ENDPOINT` are |
739 | 773 | generated automatically. `WALG_S3_PREFIX` is identical to `WALE_S3_PREFIX`. |
740 | 774 | `SCOPE` is the Postgres cluster name. |
741 | 775 |
|
@@ -874,6 +908,36 @@ on one of the other running instances (preferably replicas if they do not lag |
874 | 908 | behind). You can test restoring backups by [cloning](user.md#how-to-clone-an-existing-postgresql-cluster) |
875 | 909 | clusters. |
876 | 910 |
|
| 911 | +If you need to provide a [custom clone environment](#custom-pod-environment-variables) |
| 912 | +copy existing variables about your setup (backup location, prefix, access |
| 913 | +keys etc.) and prepend the `CLONE_` prefix to get them copied to the correct |
| 914 | +directory within Spilo. |
| 915 | + |
| 916 | +```yaml |
| 917 | +apiVersion: v1 |
| 918 | +kind: ConfigMap |
| 919 | +metadata: |
| 920 | + name: postgres-pod-config |
| 921 | +data: |
| 922 | + AWS_REGION: "eu-west-1" |
| 923 | + AWS_ACCESS_KEY_ID: "****" |
| 924 | + AWS_SECRET_ACCESS_KEY: "****" |
| 925 | + ... |
| 926 | + CLONE_AWS_REGION: "eu-west-1" |
| 927 | + CLONE_AWS_ACCESS_KEY_ID: "****" |
| 928 | + CLONE_AWS_SECRET_ACCESS_KEY: "****" |
| 929 | + ... |
| 930 | +``` |
| 931 | + |
| 932 | +### Standby clusters |
| 933 | + |
| 934 | +The setup for [standby clusters](user.md#setting-up-a-standby-cluster) is very |
| 935 | +similar to cloning. At the moment, the operator only allows for streaming from |
| 936 | +the S3 WAL archive of the master specified in the manifest. Like with cloning, |
| 937 | +if you are using [additional environment variables](#custom-pod-environment-variables) |
| 938 | +to access your backup location you have to copy those variables and prepend the |
| 939 | +`STANDBY_` prefix for Spilo to find the backups and WAL files to stream. |
| 940 | + |
877 | 941 | ## Logical backups |
878 | 942 |
|
879 | 943 | The operator can manage K8s cron jobs to run logical backups (SQL dumps) of |
|
0 commit comments