@@ -160,3 +160,81 @@ The pod anti-affinity rule to prefer not to be scheduled onto a node if that nod
160160 topologyKey: "kubernetes.io/hostname"
161161{ {- end -} }
162162
163+ { {/*
164+ The affinity
165+ */} }
166+ { {- define " monochart.affinity" -} }
167+ { {- $root := first . } }
168+ { {- $specific := last . } }
169+ { {- $config := mergeOverwrite $root .Values.affinity (get $specific " affinity" ) -} }
170+ { {- if $config } }
171+ affinity:
172+ { {- if or $config .podAntiAffinity (eq $config .affinityRule " ShouldBeOnDifferentNode" ) } }
173+ podAntiAffinity:
174+ preferredDuringSchedulingIgnoredDuringExecution:
175+ { {- if $config .podAntiAffinity } }
176+ { {- if $config .podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution } }
177+ { {- with $config .podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution } }
178+ { { toYaml . | indent 6 } }
179+ { {- end } }
180+ { {- end } }
181+ { {- end } }
182+ { {- if eq $config .affinityRule " ShouldBeOnDifferentNode" } }
183+ { {- include " monochart.affinityRule.ShouldBeOnDifferentNode" $root | nindent 6 } }
184+ { {- end } }
185+ { {- end } }
186+ { {- if $config .podAffinity } }
187+ podAffinity:
188+ requiredDuringSchedulingIgnoredDuringExecution:
189+ { {- with $config .podAffinity.requiredDuringSchedulingIgnoredDuringExecution } }
190+ { { toYaml . | indent 6 } }
191+ { {- end } }
192+ { {- end } }
193+ { {- if $config .nodeAffinity } }
194+ nodeAffinity:
195+ requiredDuringSchedulingIgnoredDuringExecution:
196+ { {- if $config .nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution } }
197+ { {- with $config .nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution } }
198+ { { toYaml . | indent 6 } }
199+ { {- end } }
200+ { {- end } }
201+ preferredDuringSchedulingIgnoredDuringExecution:
202+ { {- if $config .nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution } }
203+ { {- with $config .nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution } }
204+ { { toYaml . | indent 6 } }
205+ { {- end } }
206+ { {- end } }
207+ { {- end } }
208+ { {- end } }
209+
210+ { {- end -} }
211+
212+ { {/*
213+ The nodeSelector
214+ */} }
215+ { {- define " monochart.nodeSelector" -} }
216+ { {- $root := first . } }
217+ { {- $specific := last . } }
218+ { {- $config := mergeOverwrite $root .Values.nodeSelector (get $specific " nodeSelector" ) -} }
219+ { {- if $config } }
220+ { {- with $config } }
221+ nodeSelector:
222+ { { toYaml . | indent 2 } }
223+ { {- end } }
224+ { {- end } }
225+ { {- end -} }
226+
227+ { {/*
228+ The tolerations
229+ */} }
230+ { {- define " monochart.tolerations" -} }
231+ { {- $root := first . } }
232+ { {- $specific := last . } }
233+ { {- $config := default $root .Values.tolerations (get $specific " tolerations" ) -} }
234+ { {- if $config } }
235+ { {- with $config } }
236+ tolerations:
237+ { { toYaml . | indent 2 } }
238+ { {- end } }
239+ { {- end } }
240+ { {- end -} }
0 commit comments