Skip to content

Commit dde13cb

Browse files
committed
feat(postgres): Add pod and node affinity
ref: #18
1 parent ffed3da commit dde13cb

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

manifests/postgres/base/Cluster.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,29 @@ spec:
1313
affinity:
1414
additionalPodAntiAffinity:
1515
preferredDuringSchedulingIgnoredDuringExecution:
16-
- weight: 50
16+
- weight: 100
1717
podAffinityTerm:
1818
labelSelector:
1919
matchExpressions:
20-
- key: kubernetes.io/hostname
21-
operator: Exists
20+
- key: app.kubernetes.io/name
21+
operator: In
22+
values:
23+
- postgres
2224
topologyKey: kubernetes.io/hostname
2325

2426
enablePodAntiAffinity: true
2527
nodeAffinity:
2628
preferredDuringSchedulingIgnoredDuringExecution:
29+
- weight: 100
30+
preference:
31+
matchExpressions:
32+
- key: node-role.kubernetes.io/control-plane
33+
operator: Exists
34+
- weight: 50
35+
preference:
36+
matchExpressions:
37+
- key: node-role.kubernetes.io/master
38+
operator: Exists
2739
- weight: 100
2840
preference:
2941
matchExpressions:

manifests/postgres/components/ha/Cluster-main-02.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,33 @@ metadata:
99
app.kubernetes.io/part-of: production-ha
1010
name: main-02
1111
spec:
12+
1213
affinity:
1314
additionalPodAntiAffinity:
1415
preferredDuringSchedulingIgnoredDuringExecution:
15-
- weight: 50
16+
- weight: 100
1617
podAffinityTerm:
1718
labelSelector:
1819
matchExpressions:
19-
- key: kubernetes.io/hostname
20-
operator: Exists
20+
- key: app.kubernetes.io/name
21+
operator: In
22+
values:
23+
- postgres
2124
topologyKey: kubernetes.io/hostname
2225

2326
enablePodAntiAffinity: true
2427
nodeAffinity:
2528
preferredDuringSchedulingIgnoredDuringExecution:
29+
- weight: 100
30+
preference:
31+
matchExpressions:
32+
- key: node-role.kubernetes.io/control-plane
33+
operator: Exists
34+
- weight: 50
35+
preference:
36+
matchExpressions:
37+
- key: node-role.kubernetes.io/master
38+
operator: Exists
2639
- weight: 100
2740
preference:
2841
matchExpressions:

manifests/postgres/components/ha/kustomization.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ patches:
3737
# yamllint disable rule:indentation
3838
- patch: |-
3939
40+
- op: add
41+
path: /spec/affinity/additionalPodAntiAffinity/preferredDuringSchedulingIgnoredDuringExecution/0
42+
value:
43+
weight: 100
44+
podAffinityTerm:
45+
labelSelector:
46+
matchExpressions:
47+
- key: app.kubernetes.io/part-of
48+
operator: In
49+
values:
50+
- production-ha
51+
topologyKey: kubernetes.io/hostname
52+
53+
4054
- op: replace
4155
path: /spec/externalClusters
4256
value:

0 commit comments

Comments
 (0)