1
{{/* affinity - https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ */}}
3
{{ define "nodeaffinity" }}
5
requiredDuringSchedulingIgnoredDuringExecution:
6
{{- include "nodeAffinityRequiredDuringScheduling" . }}
7
preferredDuringSchedulingIgnoredDuringExecution:
8
{{- include "nodeAffinityPreferredDuringScheduling" . }}
11
{{- define "nodeAffinityRequiredDuringScheduling" }}
12
{{- $nodeSelector := default .global.defaultNodeSelector .nodeSelector -}}
13
{{- if or .global.arch $nodeSelector }}
16
{{- if .global.arch }}
17
- key: kubernetes.io/arch
20
{{- range $key, $val := .global.arch }}
21
{{- if gt ($val | int) 0 }}
26
{{- range $key, $val := $nodeSelector }}
35
{{- define "nodeAffinityPreferredDuringScheduling" }}
36
{{- range $key, $val := .global.arch }}
37
{{- if gt ($val | int) 0 }}
38
- weight: {{ $val | int }}
41
- key: kubernetes.io/arch
49
{{- define "podAntiAffinity" }}
50
{{- if or .podAntiAffinityLabelSelector .podAntiAffinityTermLabelSelector}}
52
{{- if .podAntiAffinityLabelSelector }}
53
requiredDuringSchedulingIgnoredDuringExecution:
54
{{- include "podAntiAffinityRequiredDuringScheduling" . }}
56
{{- if .podAntiAffinityTermLabelSelector }}
57
preferredDuringSchedulingIgnoredDuringExecution:
58
{{- include "podAntiAffinityPreferredDuringScheduling" . }}
63
{{- define "podAntiAffinityRequiredDuringScheduling" }}
64
{{- range $index, $item := .podAntiAffinityLabelSelector }}
67
- key: {{ $item.key }}
68
operator: {{ $item.operator }}
69
{{- if $item.values }}
71
{{- $vals := split "," $item.values }}
72
{{- range $i, $v := $vals }}
76
topologyKey: {{ $item.topologyKey }}
77
{{- if $item.namespaces }}
79
{{- $ns := split "," $item.namespaces }}
80
{{- range $i, $n := $ns }}
87
{{- define "podAntiAffinityPreferredDuringScheduling" }}
88
{{- range $index, $item := .podAntiAffinityTermLabelSelector }}
92
- key: {{ $item.key }}
93
operator: {{ $item.operator }}
94
{{- if $item.values }}
96
{{- $vals := split "," $item.values }}
97
{{- range $i, $v := $vals }}
101
topologyKey: {{ $item.topologyKey }}