mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-04 14:51:59 +02:00
toleration diff and nodeReadinessLabel merge with manifest matchExpressions (#1729)
* include tolerations in statefulset comparison * provide alternative merge behavior of nodeSelectorTerms for node readiness label * add config option to change affinity merge behavior * reworked e2e tests around node affinity
This commit is contained in:
@@ -339,6 +339,81 @@ master pods from being evicted by the K8s runtime. To prevent eviction
|
||||
completely, specify the toleration by leaving out the `tolerationSeconds` value
|
||||
(similar to how Kubernetes' own DaemonSets are configured)
|
||||
|
||||
## Node readiness labels
|
||||
|
||||
The operator can watch on certain node labels to detect e.g. the start of a
|
||||
Kubernetes cluster upgrade procedure and move master pods off the nodes to be
|
||||
decommissioned. Key-value pairs for these node readiness labels can be
|
||||
specified in the configuration (option name is in singular form):
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: postgres-operator
|
||||
data:
|
||||
node_readiness_label: "status1:ready,status2:ready"
|
||||
```
|
||||
|
||||
```yaml
|
||||
apiVersion: "acid.zalan.do/v1"
|
||||
kind: OperatorConfiguration
|
||||
metadata:
|
||||
name: postgresql-configuration
|
||||
configuration:
|
||||
kubernetes:
|
||||
node_readiness_label:
|
||||
status1: ready
|
||||
status2: ready
|
||||
```
|
||||
|
||||
The operator will create a `nodeAffinity` on the pods. This makes the
|
||||
`node_readiness_label` option the global configuration for defining node
|
||||
affinities for all Postgres clusters. You can have both, cluster-specific and
|
||||
global affinity, defined and they will get merged on the pods. If
|
||||
`node_readiness_label_merge` is configured to `"AND"` the node readiness
|
||||
affinity will end up under the same `matchExpressions` section(s) from the
|
||||
manifest affinity.
|
||||
|
||||
```yaml
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: environment
|
||||
operator: In
|
||||
values:
|
||||
- pci
|
||||
- key: status1
|
||||
operator: In
|
||||
values:
|
||||
- ready
|
||||
- key: status2
|
||||
...
|
||||
```
|
||||
|
||||
If `node_readiness_label_merge` is set to `"OR"` (default) the readiness label
|
||||
affinty will be appended with its own expressions block:
|
||||
|
||||
```yaml
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: environment
|
||||
...
|
||||
- matchExpressions:
|
||||
- key: storage
|
||||
...
|
||||
- matchExpressions:
|
||||
- key: status1
|
||||
...
|
||||
- key: status2
|
||||
...
|
||||
```
|
||||
|
||||
## Enable pod anti affinity
|
||||
|
||||
To ensure Postgres pods are running on different topologies, you can use
|
||||
|
||||
@@ -344,11 +344,16 @@ configuration they are grouped under the `kubernetes` key.
|
||||
|
||||
* **node_readiness_label**
|
||||
a set of labels that a running and active node should possess to be
|
||||
considered `ready`. The operator uses values of those labels to detect the
|
||||
start of the Kubernetes cluster upgrade procedure and move master pods off
|
||||
the nodes to be decommissioned. When the set is not empty, the operator also
|
||||
assigns the `Affinity` clause to the Postgres pods to be scheduled only on
|
||||
`ready` nodes. The default is empty.
|
||||
considered `ready`. When the set is not empty, the operator assigns the
|
||||
`nodeAffinity` clause to the Postgres pods to be scheduled only on `ready`
|
||||
nodes. The default is empty.
|
||||
|
||||
* **node_readiness_label_merge**
|
||||
If a `nodeAffinity` is also specified in the postgres cluster manifest
|
||||
it will get merged with the `node_readiness_label` affinity on the pods.
|
||||
The merge strategy can be configured - it can either be "AND" or "OR".
|
||||
See [user docs](../user.md#use-taints-tolerations-and-node-affinity-for-dedicated-postgresql-nodes)
|
||||
for more details. Default is "OR".
|
||||
|
||||
* **toleration**
|
||||
a dictionary that should contain `key`, `operator`, `value` and
|
||||
|
||||
+6
-1
@@ -671,7 +671,9 @@ configured [default requests](reference/operator_parameters.md#kubernetes-resour
|
||||
|
||||
To ensure Postgres pods are running on nodes without any other application pods,
|
||||
you can use [taints and tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/)
|
||||
and configure the required toleration in the manifest.
|
||||
and configure the required toleration in the manifest. Tolerations can also be
|
||||
defined in the [operator config](administrator.md#use-taints-and-tolerations-for-dedicated-postgresql-nodes)
|
||||
to apply for all Postgres clusters.
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
@@ -703,6 +705,9 @@ spec:
|
||||
- pci
|
||||
```
|
||||
|
||||
If you need to define a `nodeAffinity` for all your Postgres clusters use the
|
||||
`node_readiness_label` [configuration](administrator.md#node-readiness-labels).
|
||||
|
||||
## In-place major version upgrade
|
||||
|
||||
Starting with Spilo 13, operator supports in-place major version upgrade to a
|
||||
|
||||
Reference in New Issue
Block a user