Skip to content

Commit 9373444

Browse files
committed
add: podAntiAffinity and podAntiAffinityTopologyKey options
1 parent c9a765f commit 9373444

8 files changed

+162
-7
lines changed

deploy/helm/kubernetes/manifests/konnectivity-agent-deployment.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,38 @@ spec:
4343
{{- with .Values.konnectivityAgent.tolerations }}
4444
{{- toYaml . | nindent 6 }}
4545
{{- end }}
46+
{{- if or .Values.konnectivityServer.affinity .Values.konnectivityServer.podAntiAffinity }}
47+
affinity:
48+
{{- with .Values.konnectivityServer.affinity }}
49+
{{- toYaml . | nindent 8 }}
50+
{{- end }}
51+
{{- if eq .Values.konnectivityServer.podAntiAffinity "hard" }}
52+
podAntiAffinity:
53+
requiredDuringSchedulingIgnoredDuringExecution:
54+
- topologyKey: "{{ .Values.konnectivityServer.podAntiAffinityTopologyKey }}"
55+
labelSelector:
56+
matchLabels:
57+
app: {{ $fullName }}-konnectivity-server
58+
{{- else if eq .Values.konnectivityServer.podAntiAffinity "soft" }}
59+
podAntiAffinity:
60+
preferredDuringSchedulingIgnoredDuringExecution:
61+
- weight: 1
62+
podAffinityTerm:
63+
topologyKey: "{{ .Values.konnectivityServer.podAntiAffinityTopologyKey }}"
64+
labelSelector:
65+
matchLabels:
66+
app: {{ $fullName }}-konnectivity-server
67+
{{- end }}
68+
{{- end }}
69+
{{- with .Values.konnectivityServer.image.pullSecrets }}
70+
imagePullSecrets:
71+
{{- toYaml . | nindent 10 }}
72+
{{- end }}
4673
containers:
4774
- name: konnectivity-agent
4875
{{- with .Values.konnectivityAgent.image }}
4976
image: "{{ .repository }}{{ if .digest }}@{{ .digest }}{{ else }}:{{ .tag }}{{ end }}"
77+
imagePullPolicy: {{ .pullPolicy }}
5078
{{- end }}
5179
command:
5280
- /proxy-agent

deploy/helm/kubernetes/templates/admin-deployment.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,28 @@ spec:
3939
tolerations:
4040
{{- toYaml . | nindent 6 }}
4141
{{- end }}
42-
{{- with .Values.admin.affinity }}
42+
{{- if or .Values.admin.affinity .Values.admin.podAntiAffinity }}
4343
affinity:
44+
{{- with .Values.admin.affinity }}
4445
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
{{- if eq .Values.admin.podAntiAffinity "hard" }}
48+
podAntiAffinity:
49+
requiredDuringSchedulingIgnoredDuringExecution:
50+
- topologyKey: "{{ .Values.admin.podAntiAffinityTopologyKey }}"
51+
labelSelector:
52+
matchLabels:
53+
app: {{ $fullName }}-admin
54+
{{- else if eq .Values.admin.podAntiAffinity "soft" }}
55+
podAntiAffinity:
56+
preferredDuringSchedulingIgnoredDuringExecution:
57+
- weight: 1
58+
podAffinityTerm:
59+
topologyKey: "{{ .Values.admin.podAntiAffinityTopologyKey }}"
60+
labelSelector:
61+
matchLabels:
62+
app: {{ $fullName }}-admin
63+
{{- end }}
4564
{{- end }}
4665
{{- with .Values.admin.image.pullSecrets }}
4766
imagePullSecrets:

deploy/helm/kubernetes/templates/apiserver-deployment.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,28 @@ spec:
4141
tolerations:
4242
{{- toYaml . | nindent 6 }}
4343
{{- end }}
44-
{{- with .Values.apiServer.affinity }}
44+
{{- if or .Values.apiServer.affinity .Values.apiServer.podAntiAffinity }}
4545
affinity:
46+
{{- with .Values.apiServer.affinity }}
4647
{{- toYaml . | nindent 8 }}
48+
{{- end }}
49+
{{- if eq .Values.apiServer.podAntiAffinity "hard" }}
50+
podAntiAffinity:
51+
requiredDuringSchedulingIgnoredDuringExecution:
52+
- topologyKey: "{{ .Values.apiServer.podAntiAffinityTopologyKey }}"
53+
labelSelector:
54+
matchLabels:
55+
app: {{ $fullName }}-apiserver
56+
{{- else if eq .Values.apiServer.podAntiAffinity "soft" }}
57+
podAntiAffinity:
58+
preferredDuringSchedulingIgnoredDuringExecution:
59+
- weight: 1
60+
podAffinityTerm:
61+
topologyKey: "{{ .Values.apiServer.podAntiAffinityTopologyKey }}"
62+
labelSelector:
63+
matchLabels:
64+
app: {{ $fullName }}-apiserver
65+
{{- end }}
4766
{{- end }}
4867
{{- with .Values.apiServer.image.pullSecrets }}
4968
imagePullSecrets:

deploy/helm/kubernetes/templates/controller-manager-deployment.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,28 @@ spec:
3939
tolerations:
4040
{{- toYaml . | nindent 6 }}
4141
{{- end }}
42-
{{- with .Values.controllerManager.affinity }}
42+
{{- if or .Values.controllerManager.affinity .Values.controllerManager.podAntiAffinity }}
4343
affinity:
44+
{{- with .Values.controllerManager.affinity }}
4445
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
{{- if eq .Values.controllerManager.podAntiAffinity "hard" }}
48+
podAntiAffinity:
49+
requiredDuringSchedulingIgnoredDuringExecution:
50+
- topologyKey: "{{ .Values.controllerManager.podAntiAffinityTopologyKey }}"
51+
labelSelector:
52+
matchLabels:
53+
app: {{ $fullName }}-controller-manager
54+
{{- else if eq .Values.controllerManager.podAntiAffinity "soft" }}
55+
podAntiAffinity:
56+
preferredDuringSchedulingIgnoredDuringExecution:
57+
- weight: 1
58+
podAffinityTerm:
59+
topologyKey: "{{ .Values.controllerManager.podAntiAffinityTopologyKey }}"
60+
labelSelector:
61+
matchLabels:
62+
app: {{ $fullName }}-controller-manager
63+
{{- end }}
4564
{{- end }}
4665
{{- with .Values.controllerManager.image.pullSecrets }}
4766
imagePullSecrets:

deploy/helm/kubernetes/templates/etcd-statefulset.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,29 @@ spec:
4242
tolerations:
4343
{{- toYaml . | nindent 6 }}
4444
{{- end }}
45-
{{- with .Values.etcd.affinity }}
45+
{{- if or .Values.etcd.affinity .Values.etcd.podAntiAffinity }}
4646
affinity:
47+
{{- with .Values.etcd.affinity }}
4748
{{- toYaml . | nindent 8 }}
49+
{{- end }}
50+
{{- if eq .Values.etcd.podAntiAffinity "hard" }}
51+
podAntiAffinity:
52+
requiredDuringSchedulingIgnoredDuringExecution:
53+
- topologyKey: "{{ .Values.etcd.podAntiAffinityTopologyKey }}"
54+
labelSelector:
55+
matchLabels:
56+
app: {{ $fullName }}-etcd
57+
{{- else if eq .Values.etcd.podAntiAffinity "soft" }}
58+
podAntiAffinity:
59+
preferredDuringSchedulingIgnoredDuringExecution:
60+
- weight: 1
61+
podAffinityTerm:
62+
topologyKey: "{{ .Values.etcd.podAntiAffinityTopologyKey }}"
63+
labelSelector:
64+
matchLabels:
65+
app: {{ $fullName }}-etcd
66+
{{- end }}
4867
{{- end }}
49-
5068
{{- with .Values.etcd.image.pullSecrets }}
5169
imagePullSecrets:
5270
{{- toYaml . | nindent 10 }}

deploy/helm/kubernetes/templates/konnectivity-server-deployment.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,28 @@ spec:
3939
tolerations:
4040
{{- toYaml . | nindent 6 }}
4141
{{- end }}
42-
{{- with .Values.konnectivityServer.affinity }}
42+
{{- if or .Values.konnectivityServer.affinity .Values.konnectivityServer.podAntiAffinity }}
4343
affinity:
44+
{{- with .Values.konnectivityServer.affinity }}
4445
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
{{- if eq .Values.konnectivityServer.podAntiAffinity "hard" }}
48+
podAntiAffinity:
49+
requiredDuringSchedulingIgnoredDuringExecution:
50+
- topologyKey: "{{ .Values.konnectivityServer.podAntiAffinityTopologyKey }}"
51+
labelSelector:
52+
matchLabels:
53+
app: {{ $fullName }}-konnectivity-server
54+
{{- else if eq .Values.konnectivityServer.podAntiAffinity "soft" }}
55+
podAntiAffinity:
56+
preferredDuringSchedulingIgnoredDuringExecution:
57+
- weight: 1
58+
podAffinityTerm:
59+
topologyKey: "{{ .Values.konnectivityServer.podAntiAffinityTopologyKey }}"
60+
labelSelector:
61+
matchLabels:
62+
app: {{ $fullName }}-konnectivity-server
63+
{{- end }}
4564
{{- end }}
4665
{{- with .Values.konnectivityServer.image.pullSecrets }}
4766
imagePullSecrets:

deploy/helm/kubernetes/templates/scheduler-deployment.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,28 @@ spec:
3939
tolerations:
4040
{{- toYaml . | nindent 6 }}
4141
{{- end }}
42-
{{- with .Values.scheduler.affinity }}
42+
{{- if or .Values.scheduler.affinity .Values.scheduler.podAntiAffinity }}
4343
affinity:
44+
{{- with .Values.scheduler.affinity }}
4445
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
{{- if eq .Values.scheduler.podAntiAffinity "hard" }}
48+
podAntiAffinity:
49+
requiredDuringSchedulingIgnoredDuringExecution:
50+
- topologyKey: "{{ .Values.scheduler.podAntiAffinityTopologyKey }}"
51+
labelSelector:
52+
matchLabels:
53+
app: {{ $fullName }}-scheduler
54+
{{- else if eq .Values.scheduler.podAntiAffinity "soft" }}
55+
podAntiAffinity:
56+
preferredDuringSchedulingIgnoredDuringExecution:
57+
- weight: 1
58+
podAffinityTerm:
59+
topologyKey: "{{ .Values.scheduler.podAntiAffinityTopologyKey }}"
60+
labelSelector:
61+
matchLabels:
62+
app: {{ $fullName }}-scheduler
63+
{{- end }}
4564
{{- end }}
4665
{{- with .Values.scheduler.image.pullSecrets }}
4766
imagePullSecrets:

deploy/helm/kubernetes/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ etcd:
3939
podAnnotations: {}
4040
nodeSelector: {}
4141
tolerations: []
42+
podAntiAffinity: soft
43+
podAntiAffinityTopologyKey: kubernetes.io/hostname
4244
affinity: {}
4345
extraEnv: []
4446
sidecars: []
@@ -89,6 +91,8 @@ apiServer:
8991
podAnnotations: {}
9092
nodeSelector: {}
9193
tolerations: []
94+
podAntiAffinity: soft
95+
podAntiAffinityTopologyKey: kubernetes.io/hostname
9296
affinity: {}
9397
extraEnv: []
9498
sidecars: []
@@ -130,6 +134,8 @@ controllerManager:
130134
podAnnotations: {}
131135
nodeSelector: {}
132136
tolerations: []
137+
podAntiAffinity: soft
138+
podAntiAffinityTopologyKey: kubernetes.io/hostname
133139
affinity: {}
134140
extraEnv: []
135141
sidecars: []
@@ -168,6 +174,8 @@ scheduler:
168174
podAnnotations: {}
169175
nodeSelector: {}
170176
tolerations: []
177+
podAntiAffinity: soft
178+
podAntiAffinityTopologyKey: kubernetes.io/hostname
171179
affinity: {}
172180
extraEnv: []
173181
sidecars: []
@@ -211,6 +219,8 @@ admin:
211219
podAnnotations: {}
212220
nodeSelector: {}
213221
tolerations: []
222+
podAntiAffinity: soft
223+
podAntiAffinityTopologyKey: kubernetes.io/hostname
214224
affinity: {}
215225
extraEnv: []
216226
sidecars: []
@@ -246,6 +256,8 @@ konnectivityServer:
246256
podAnnotations: {}
247257
nodeSelector: {}
248258
tolerations: []
259+
podAntiAffinity: soft
260+
podAntiAffinityTopologyKey: kubernetes.io/hostname
249261
affinity: {}
250262
extraEnv: []
251263
sidecars: []
@@ -289,6 +301,8 @@ konnectivityAgent:
289301
podAnnotations: {}
290302
nodeSelector: {}
291303
tolerations: []
304+
podAntiAffinity: soft
305+
podAntiAffinityTopologyKey: kubernetes.io/hostname
292306
affinity: {}
293307
extraEnv: []
294308
sidecars: []

0 commit comments

Comments
 (0)