Skip to content

Commit eb0c222

Browse files
author
yb
committed
[feature]add pod affinity
1 parent 434dd8d commit eb0c222

File tree

4 files changed

+344
-79
lines changed

4 files changed

+344
-79
lines changed

platforms/kubernetes/postgres-operator/deploy/postgres-operator.yaml.template

+17
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ spec:
9999
enum:
100100
- true
101101
- false
102+
antiaffinity:
103+
type: object
104+
x-kubernetes-preserve-unknown-fields: true
105+
properties:
106+
policy:
107+
type: string
108+
enum:
109+
- 'preferred'
110+
- 'required'
111+
podAntiAffinityTerm:
112+
type: string
113+
enum:
114+
- 'none'
115+
- 'autofailover-readwrite'
116+
- 'autofailover-readwrite-readonly'
117+
topologyKey:
118+
type: string
102119
services:
103120
type: array
104121
items:

platforms/kubernetes/postgres-operator/deploy/postgresql.yaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ metadata:
66
spec:
77
action: start #stop start
88
deletepvc: true
9+
antiaffinity:
10+
policy: preferred # preferred/required
11+
podAntiAffinityTerm: autofailover-readwrite # none/autofailover-readwrite/autofailover-readwrite-readonly
12+
topologyKey: "kubernetes.io/hostname" # when policy is required, only allow "kubernetes.io/hostname"
913
services:
1014
- selector: primary # autofailover/primary/standby/readonly/standby-readonly
1115
metadata:
@@ -31,7 +35,7 @@ spec:
3135
podspec:
3236
terminationGracePeriodSeconds: 60
3337
containers:
34-
- image: radondb-postgresql:12.9-v1.0.0
38+
- image: radondb-postgresql:12.12-v1.0.0
3539
imagePullPolicy: IfNotPresent
3640
name: postgresql #can't change the name
3741
volumeMounts:
@@ -74,7 +78,7 @@ spec:
7478
podspec:
7579
terminationGracePeriodSeconds: 60
7680
containers:
77-
- image: radondb-postgresql:12.9-v1.0.0
81+
- image: radondb-postgresql:12.12-v1.0.0
7882
imagePullPolicy: IfNotPresent
7983
name: postgresql #can't change the name
8084
volumeMounts:
@@ -101,7 +105,7 @@ spec:
101105
podspec:
102106
terminationGracePeriodSeconds: 60
103107
containers:
104-
- image: radondb-postgresql:12.9-v1.0.0
108+
- image: radondb-postgresql:12.12-v1.0.0
105109
imagePullPolicy: IfNotPresent
106110
name: postgresql #can't change the name
107111
volumeMounts:

platforms/kubernetes/postgres-operator/postgres/constants.py

+10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@
105105
MACHINE_MODE = "machine"
106106
K8S_MODE = "k8s"
107107

108+
# antiaffinity
109+
SPEC_ANTIAFFINITY = "antiaffinity"
110+
SPEC_ANTIAFFINITY_POLICY = "policy"
111+
SPEC_ANTIAFFINITY_REQUIRED = "required"
112+
SPEC_ANTIAFFINITY_PREFERRED = "preferred"
113+
SPEC_ANTIAFFINITY_POLICY_REQUIRED = "requiredDuringSchedulingIgnoredDuringExecution"
114+
SPEC_ANTIAFFINITY_POLICY_PREFERRED = "preferredDuringSchedulingIgnoredDuringExecution"
115+
SPEC_ANTIAFFINITY_PODANTIAFFINITYTERM = "podAntiAffinityTerm"
116+
SPEC_ANTIAFFINITY_TOPOLOGYKEY = "topologyKey"
117+
108118
# docker-compose
109119
DOCKER_COMPOSE_FILE = "docker-compose.yaml"
110120
DOCKER_COMPOSE_FILE_DATA = '''

0 commit comments

Comments
 (0)