You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-12Lines changed: 21 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,29 +6,38 @@
6
6
7
7
The Postgres operator manages PostgreSQL clusters on Kubernetes using the [operator pattern](https://coreos.com/blog/introducing-operators.html).
8
8
During the initial run it registers the [Custom Resource Definition (CRD)](https://kubernetes.io/docs/concepts/api-extension/custom-resources/#customresourcedefinitions) for Postgres.
9
-
The PostgreSQL CRD is essentially the schema that describes the contents of the manifests for deploying individual
9
+
The PostgreSQL CRD is essentially the schema that describes the contents of the manifests for deploying individual
10
10
PostgreSQL clusters using StatefulSets and [Patroni](https://github.com/zalando/patroni).
11
11
12
12
Once the operator is running, it performs the following actions:
13
13
14
14
* watches for new PostgreSQL cluster manifests and deploys corresponding clusters
15
15
* watches for updates to existing manifests and changes corresponding properties of the running clusters
16
16
* watches for deletes of the existing manifests and deletes corresponding clusters
17
-
* acts on an update to the operator definition itself and changes the running clusters when necessary
17
+
* acts on an update to the operator definition itself and changes the running clusters when necessary
18
18
(i.e. when the docker image inside the operator definition has been updated)
19
19
* periodically checks running clusters against the manifests and acts on the differences found
20
20
21
-
For instance, when the user creates a new custom object of type ``postgresql`` by submitting a new manifest with
22
-
``kubectl``, the operator fetches that object and creates the corresponding Kubernetes structures
21
+
For instance, when the user creates a new custom object of type ``postgresql`` by submitting a new manifest with
22
+
``kubectl``, the operator fetches that object and creates the corresponding Kubernetes structures
23
23
(StatefulSets, Services, Secrets) according to its definition.
24
24
25
25
Another example is changing the docker image inside the operator. In this case, the operator first goes to all StatefulSets
26
26
it manages and updates them with the new docker images; afterwards, all pods from each StatefulSet are killed one by one
27
27
(rolling upgrade) and the replacements are spawned automatically by each StatefulSet with the new docker image.
28
28
29
+
## Scope
30
+
31
+
The scope of the postgres operator is on provisioning, modifying configuration and cleaning up Postgres clusters that use Patroni, basically to make it easy and convenient to run Patroni based clusters on Kubernetes.
32
+
The provisioning and modifying includes Kubernetes resources on one side but also e.g. database and role provisioning once the cluster is up and running.
33
+
We try to leave as much work as possible to Kubernetes and to Patroni where it fits, especially the cluster bootstrap and high availability.
34
+
The operator is however involved in some overarching orchestration, like rolling upgrades to improve the user experience.
35
+
36
+
Monitoring of clusters is not in scope, for this good tools already exist from ZMON to Prometheus and more Postgres specific options.
37
+
29
38
## Status
30
39
31
-
This project is currently in active development. It is however already [used internally by Zalando](https://jobs.zalando.com/tech/blog/postgresql-in-a-time-of-kubernetes/) in order to run Postgres databases on Kubernetes in larger numbers for staging environments and a smaller number of production databases. In this environment the operator is deployed to multiple Kubernetes clusters, where users deploy manifests via our CI/CD infrastructure.
40
+
This project is currently in active development. It is however already [used internally by Zalando](https://jobs.zalando.com/tech/blog/postgresql-in-a-time-of-kubernetes/) in order to run Postgres clusters on Kubernetes in larger numbers for staging environments and a growing number of production clusters. In this environment the operator is deployed to multiple Kubernetes clusters, where users deploy manifests via our CI/CD infrastructure or rely on a slim user interface to create manifests.
32
41
33
42
Please, report any issues discovered to https://github.com/zalando-incubator/postgres-operator/issues.
34
43
@@ -40,7 +49,7 @@ Please, report any issues discovered to https://github.com/zalando-incubator/pos
40
49
41
50
## Running and testing the operator
42
51
43
-
The best way to test the operator is to run it in [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/).
52
+
The best way to test the operator is to run it in [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/).
44
53
Minikube is a tool to run Kubernetes cluster locally.
45
54
46
55
### Installing and starting minikube
@@ -72,11 +81,11 @@ All subsequent `kubectl` commands will work with the `test` namespace. The opera
72
81
73
82
### Specify the namespace to watch
74
83
75
-
Watching a namespace for an operator means tracking requests to change Postgresql clusters in the namespace such as "increase the number of Postgresql replicas to 5" and reacting to the requests, in this example by actually scaling up.
84
+
Watching a namespace for an operator means tracking requests to change Postgresql clusters in the namespace such as "increase the number of Postgresql replicas to 5" and reacting to the requests, in this example by actually scaling up.
76
85
77
86
By default, the operator watches the namespace it is deployed to. You can change this by altering the `WATCHED_NAMESPACE` env var in the operator deployment manifest or the `watched_namespace` field in the operator configmap. In the case both are set, the env var takes the precedence. To make the operator listen to all namespaces, explicitly set the field/env var to "`*`".
78
87
79
-
Note that for an operator to manage pods in the watched namespace, the operator's service account (as specified in the operator deployment manifest) has to have appropriate privileges to access the watched namespace. The operator may not be able to function in the case it watches all namespaces but lacks access rights to any of them (except Kubernetes system namespaces like `kube-system`). The reason is that for multiple namespaces operations such as 'list pods' execute at the cluster scope and fail at the first violation of access rights.
88
+
Note that for an operator to manage pods in the watched namespace, the operator's service account (as specified in the operator deployment manifest) has to have appropriate privileges to access the watched namespace. The operator may not be able to function in the case it watches all namespaces but lacks access rights to any of them (except Kubernetes system namespaces like `kube-system`). The reason is that for multiple namespaces operations such as 'list pods' execute at the cluster scope and fail at the first violation of access rights.
80
89
81
90
The watched namespace also needs to have a (possibly different) service account in the case database pods need to talk to the Kubernetes API (e.g. when using Kubernetes-native configuration of Patroni).
82
91
@@ -131,8 +140,8 @@ The operator can be configured with the provided ConfigMap (`manifests/configmap
131
140
132
141
#### Use taints and tolerations for dedicated PostgreSQL nodes
133
142
134
-
To ensure Postgres pods are running on nodes without any other application pods, you can use
135
-
[taints and tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) and configure the
143
+
To ensure Postgres pods are running on nodes without any other application pods, you can use
144
+
[taints and tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) and configure the
136
145
required toleration in the operator ConfigMap.
137
146
138
147
As an example you can set following node taint:
@@ -168,7 +177,7 @@ spec:
168
177
effect: NoSchedule
169
178
```
170
179
171
-
Please be aware that the taint and toleration only ensures that no other pod gets scheduled to a PostgreSQL node
180
+
Please be aware that the taint and toleration only ensures that no other pod gets scheduled to a PostgreSQL node
172
181
but not that PostgreSQL pods are placed on such a node. This can be achieved by setting a node affinity rule in the ConfigMap.
173
182
174
183
### Using the operator to minimize the amount of failovers during the cluster upgrade
0 commit comments