Skip to content

Commit 97e0d6d

Browse files
authored
extend docs and polish manifest examples (#762)
1 parent bfe2e70 commit 97e0d6d

File tree

12 files changed

+111
-109
lines changed

12 files changed

+111
-109
lines changed

docs/administrator.md

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
Learn how to configure and manage the Postgres Operator in your Kubernetes (K8s)
44
environment.
55

6+
## Minor and major version upgrade
7+
8+
Minor version upgrades for PostgreSQL are handled via updating the Spilo Docker
9+
image. The operator will carry out a rolling update of Pods which includes a
10+
switchover (planned failover) of the master to the Pod with new minor version.
11+
The switch should usually take less than 5 seconds, still clients have to
12+
reconnect.
13+
14+
Major version upgrades are supported via [cloning](user.md#clone-directly). The
15+
new cluster manifest must have a higher `version` string than the source cluster
16+
and will be created from a basebackup. Depending of the cluster size, downtime
17+
in this case can be significant as writes to the database should be stopped and
18+
all WAL files should be archived first before cloning is started.
19+
20+
Note, that simply changing the version string in the `postgresql` manifest does
21+
not work at present and leads to errors. Neither Patroni nor Postgres Operator
22+
can do in place `pg_upgrade`. Still, it can be executed manually in the Postgres
23+
container, which is tricky (i.e. systems need to be stopped, replicas have to be
24+
synced) but of course faster than cloning.
25+
626
## CRD Validation
727

828
[CustomResourceDefinitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#customresourcedefinitions)
@@ -95,8 +115,6 @@ is used by the operator to connect to the clusters after creation.
95115

96116
## Role-based access control for the operator
97117

98-
### Service account and cluster roles
99-
100118
The manifest [`operator-service-account-rbac.yaml`](../manifests/operator-service-account-rbac.yaml)
101119
defines the service account, cluster roles and bindings needed for the operator
102120
to function under access control restrictions. To deploy the operator with this
@@ -109,19 +127,15 @@ kubectl create -f manifests/postgres-operator.yaml
109127
kubectl create -f manifests/minimal-postgres-manifest.yaml
110128
```
111129

130+
### Service account and cluster roles
131+
112132
Note that the service account is named `zalando-postgres-operator`. You may have
113133
to change the `service_account_name` in the operator ConfigMap and
114134
`serviceAccountName` in the `postgres-operator` deployment appropriately. This
115135
is done intentionally to avoid breaking those setups that already work with the
116136
default `operator` account. In the future the operator should ideally be run
117137
under the `zalando-postgres-operator` service account.
118138

119-
The service account defined in `operator-service-account-rbac.yaml` acquires
120-
some privileges not used by the operator (i.e. we only need `list` and `watch`
121-
on `configmaps` resources). This is also done intentionally to avoid breaking
122-
things if someone decides to configure the same service account in the
123-
operator's ConfigMap to run Postgres clusters.
124-
125139
### Give K8s users access to create/list `postgresqls`
126140

127141
By default `postgresql` custom resources can only be listed and changed by
@@ -157,7 +171,6 @@ metadata:
157171
name: postgres-operator
158172
data:
159173
toleration: "key:postgres,operator:Exists,effect:NoSchedule"
160-
...
161174
```
162175

163176
For an OperatorConfiguration resource the toleration should be defined like
@@ -172,7 +185,6 @@ configuration:
172185
kubernetes:
173186
toleration:
174187
postgres: "key:postgres,operator:Exists,effect:NoSchedule"
175-
...
176188
```
177189

178190
Note that the K8s version 1.13 brings [taint-based eviction](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-based-evictions)
@@ -250,7 +262,6 @@ metadata:
250262
name: postgres-operator
251263
data:
252264
inherited_labels: application,environment
253-
...
254265
```
255266

256267
**OperatorConfiguration**
@@ -265,7 +276,6 @@ configuration:
265276
inherited_labels:
266277
- application
267278
- environment
268-
...
269279
```
270280

271281
**cluster manifest**
@@ -279,7 +289,7 @@ metadata:
279289
application: my-app
280290
environment: demo
281291
spec:
282-
...
292+
...
283293
```
284294

285295
**network policy**
@@ -294,7 +304,6 @@ spec:
294304
matchLabels:
295305
application: my-app
296306
environment: demo
297-
...
298307
```
299308

300309

@@ -317,7 +326,6 @@ metadata:
317326
data:
318327
# referencing config map with custom settings
319328
pod_environment_configmap: postgres-pod-config
320-
...
321329
```
322330

323331
**OperatorConfiguration**
@@ -331,7 +339,6 @@ configuration:
331339
kubernetes:
332340
# referencing config map with custom settings
333341
pod_environment_configmap: postgres-pod-config
334-
...
335342
```
336343

337344
**referenced ConfigMap `postgres-pod-config`**
@@ -412,12 +419,12 @@ external systems but defined for an individual Postgres cluster in its manifest.
412419
A typical example is a role for connections from an application that uses the
413420
database.
414421

415-
* **Human users** originate from the Teams API that returns a list of the team
416-
members given a team id. The operator differentiates between (a) product teams
417-
that own a particular Postgres cluster and are granted admin rights to maintain
418-
it, and (b) Postgres superuser teams that get the superuser access to all
419-
Postgres databases running in a K8s cluster for the purposes of maintaining and
420-
troubleshooting.
422+
* **Human users** originate from the [Teams API](user.md#teams-api-roles) that
423+
returns a list of the team members given a team id. The operator differentiates
424+
between (a) product teams that own a particular Postgres cluster and are granted
425+
admin rights to maintain it, and (b) Postgres superuser teams that get the
426+
superuser access to all Postgres databases running in a K8s cluster for the
427+
purposes of maintaining and troubleshooting.
421428

422429
## Understanding rolling update of Spilo pods
423430

@@ -481,7 +488,7 @@ A secret can be pre-provisioned in different ways:
481488

482489
With the v1.2 release the Postgres Operator is shipped with a browser-based
483490
configuration user interface (UI) that simplifies managing Postgres clusters
484-
with the operator. The UI runs with Node.js and comes with it's own docker
491+
with the operator. The UI runs with Node.js and comes with it's own Docker
485492
image.
486493

487494
Run NPM to continuously compile `tags/js` code. Basically, it creates an
@@ -493,14 +500,14 @@ Run NPM to continuously compile `tags/js` code. Basically, it creates an
493500

494501
To build the Docker image open a shell and change to the `ui` folder. Then run:
495502

496-
```
503+
```bash
497504
docker build -t registry.opensource.zalan.do/acid/postgres-operator-ui:v1.2.0 .
498505
```
499506

500507
Apply all manifests for the `ui/manifests` folder to deploy the Postgres
501508
Operator UI on K8s. For local tests you don't need the Ingress resource.
502509

503-
```
510+
```bash
504511
kubectl apply -f ui/manifests
505512
```
506513

@@ -510,6 +517,6 @@ to the K8s and Postgres Operator REST API. You can use the provided
510517
`run_local.sh` script for this. Make sure it uses the correct URL to your K8s
511518
API server, e.g. for minikube it would be `https://192.168.99.100:8443`.
512519

513-
```
520+
```bash
514521
./run_local.sh
515522
```

docs/developer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This would take a while to complete. You have to redo `make deps` every time
4040
your dependencies list changes, i.e. after adding a new library dependency.
4141

4242
Build the operator with the `make docker` command. You may define the TAG
43-
variable to assign an explicit tag to your docker image and the IMAGE to set
43+
variable to assign an explicit tag to your Docker image and the IMAGE to set
4444
the image name. By default, the tag is computed with
4545
`git describe --tags --always --dirty` and the image is
4646
`registry.opensource.zalan.do/acid/postgres-operator`
@@ -60,10 +60,10 @@ The binary will be placed into the build directory.
6060

6161
## Deploying self build image
6262

63-
The fastest way to run and test your docker image locally is to reuse the docker
64-
from [minikube](https://github.com/kubernetes/minikube/releases) or use the
65-
`load docker-image` from [kind](https://kind.sigs.k8s.io/). The following steps
66-
will get you the docker image built and deployed.
63+
The fastest way to run and test your Docker image locally is to reuse the Docker
64+
environment from [minikube](https://github.com/kubernetes/minikube/releases)
65+
or use the `load docker-image` from [kind](https://kind.sigs.k8s.io/). The
66+
following steps will get you the Docker image built and deployed.
6767

6868
```bash
6969
# minikube
@@ -162,7 +162,7 @@ The operator also supports pprof endpoints listed at the
162162
* /debug/pprof/trace
163163

164164
It's possible to attach a debugger to troubleshoot postgres-operator inside a
165-
docker container. It's possible with [gdb](https://www.gnu.org/software/gdb/)
165+
Docker container. It's possible with [gdb](https://www.gnu.org/software/gdb/)
166166
and [delve](https://github.com/derekparker/delve). Since the latter one is a
167167
specialized debugger for Go, we will use it as an example. To use it you need:
168168

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ manages PostgreSQL clusters on Kubernetes (K8s):
1313

1414
2. The operator also watches updates to [its own configuration](../manifests/configmap.yaml)
1515
and alters running Postgres clusters if necessary. For instance, if the
16-
docker image in a pod is changed, the operator carries out the rolling
16+
Docker image in a pod is changed, the operator carries out the rolling
1717
update, which means it re-spawns pods of each managed StatefulSet one-by-one
1818
with the new Docker image.
1919

docs/quickstart.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ export PGPORT=$(echo $HOST_PORT | cut -d: -f 2)
155155
```
156156

157157
Retrieve the password from the K8s Secret that is created in your cluster.
158+
Non-encrypted connections are rejected by default, so set the SSL mode to
159+
require:
158160

159161
```bash
160162
export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d)
163+
export PGSSLMODE=require
161164
psql -U postgres
162165
```
163166

docs/reference/cluster_manifest.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ These parameters are grouped directly under the `spec` key in the manifest.
6262
field.
6363

6464
* **dockerImage**
65-
custom docker image that overrides the **docker_image** operator parameter.
65+
custom Docker image that overrides the **docker_image** operator parameter.
6666
It should be a [Spilo](https://github.com/zalando/spilo) image. Optional.
6767

6868
* **spiloFSGroup**
@@ -124,7 +124,7 @@ These parameters are grouped directly under the `spec` key in the manifest.
124124

125125

126126
* **enableShmVolume**
127-
Start a database pod without limitations on shm memory. By default docker
127+
Start a database pod without limitations on shm memory. By default Docker
128128
limit `/dev/shm` to `64M` (see e.g. the [docker
129129
issue](https://github.com/docker-library/postgres/issues/416), which could be
130130
not enough if PostgreSQL uses parallel workers heavily. If this option is
@@ -185,19 +185,19 @@ explanation of `ttl` and `loop_wait` parameters.
185185

186186
* **ttl**
187187
Patroni `ttl` parameter value, optional. The default is set by the Spilo
188-
docker image. Optional.
188+
Docker image. Optional.
189189

190190
* **loop_wait**
191191
Patroni `loop_wait` parameter value, optional. The default is set by the
192-
Spilo docker image. Optional.
192+
Spilo Docker image. Optional.
193193

194194
* **retry_timeout**
195195
Patroni `retry_timeout` parameter value, optional. The default is set by the
196-
Spilo docker image. Optional.
196+
Spilo Docker image. Optional.
197197

198198
* **maximum_lag_on_failover**
199199
Patroni `maximum_lag_on_failover` parameter value, optional. The default is
200-
set by the Spilo docker image. Optional.
200+
set by the Spilo Docker image. Optional.
201201

202202
* **slots**
203203
permanent replication slots that Patroni preserves after failover by
@@ -320,7 +320,7 @@ defined in the sidecar dictionary:
320320
name of the sidecar. Required.
321321

322322
* **image**
323-
docker image of the sidecar. Required.
323+
Docker image of the sidecar. Required.
324324

325325
* **env**
326326
a dictionary of environment variables. Use usual Kubernetes definition

docs/reference/operator_parameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ Those are top-level keys, containing both leaf keys and groups.
8181
Kubernetes-native DCS).
8282

8383
* **docker_image**
84-
Spilo docker image for Postgres instances. For production, don't rely on the
84+
Spilo Docker image for Postgres instances. For production, don't rely on the
8585
default image, as it might be not the most up-to-date one. Instead, build
8686
your own Spilo image from the [github
8787
repository](https://github.com/zalando/spilo).
8888

8989
* **sidecar_docker_images**
90-
a map of sidecar names to docker images to run with Spilo. In case of the name
90+
a map of sidecar names to Docker images to run with Spilo. In case of the name
9191
conflict with the definition in the cluster manifest the cluster-specific one
9292
is preferred.
9393

0 commit comments

Comments
 (0)