istio

Форк
0
104 строки · 3.1 Кб
1
{{/* affinity - https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ */}}
2

3
{{ define "nodeaffinity" }}
4
nodeAffinity:
5
  requiredDuringSchedulingIgnoredDuringExecution:
6
  {{- include "nodeAffinityRequiredDuringScheduling" . }}
7
  preferredDuringSchedulingIgnoredDuringExecution:
8
  {{- include "nodeAffinityPreferredDuringScheduling" . }}
9
{{- end }}
10

11
{{- define "nodeAffinityRequiredDuringScheduling" }}
12
  {{- $nodeSelector := default .global.defaultNodeSelector .nodeSelector -}}
13
  {{- if or .global.arch $nodeSelector }}
14
      nodeSelectorTerms:
15
      - matchExpressions:
16
        {{- if .global.arch }}
17
        - key: kubernetes.io/arch
18
          operator: In
19
          values:
20
        {{- range $key, $val := .global.arch }}
21
          {{- if gt ($val | int) 0 }}
22
          - {{ $key | quote }}
23
          {{- end }}
24
        {{- end }}
25
        {{- end }}
26
        {{- range $key, $val := $nodeSelector }}
27
        - key: {{ $key }}
28
          operator: In
29
          values:
30
          - {{ $val | quote }}
31
        {{- end }}
32
  {{- end }}
33
{{- end }}
34

35
{{- define "nodeAffinityPreferredDuringScheduling" }}
36
  {{- range $key, $val := .global.arch }}
37
    {{- if gt ($val | int) 0 }}
38
    - weight: {{ $val | int }}
39
      preference:
40
        matchExpressions:
41
        - key: kubernetes.io/arch
42
          operator: In
43
          values:
44
          - {{ $key | quote }}
45
    {{- end }}
46
  {{- end }}
47
{{- end }}
48

49
{{- define "podAntiAffinity" }}
50
{{- if or .podAntiAffinityLabelSelector .podAntiAffinityTermLabelSelector}}
51
  podAntiAffinity:
52
    {{- if .podAntiAffinityLabelSelector }}
53
    requiredDuringSchedulingIgnoredDuringExecution:
54
    {{- include "podAntiAffinityRequiredDuringScheduling" . }}
55
    {{- end }}
56
    {{- if .podAntiAffinityTermLabelSelector }}
57
    preferredDuringSchedulingIgnoredDuringExecution:
58
    {{- include "podAntiAffinityPreferredDuringScheduling" . }}
59
    {{- end }}
60
{{- end }}
61
{{- end }}
62

63
{{- define "podAntiAffinityRequiredDuringScheduling" }}
64
    {{- range $index, $item := .podAntiAffinityLabelSelector }}
65
    - labelSelector:
66
        matchExpressions:
67
        - key: {{ $item.key }}
68
          operator: {{ $item.operator }}
69
          {{- if $item.values }}
70
          values:
71
          {{- $vals := split "," $item.values }}
72
          {{- range $i, $v := $vals }}
73
          - {{ $v | quote }}
74
          {{- end }}
75
          {{- end }}
76
      topologyKey: {{ $item.topologyKey }}
77
      {{- if $item.namespaces }}
78
      namespaces:
79
      {{- $ns := split "," $item.namespaces }}
80
      {{- range $i, $n := $ns }}
81
      - {{ $n | quote }}
82
      {{- end }}
83
      {{- end }}
84
    {{- end }}
85
{{- end }}
86

87
{{- define "podAntiAffinityPreferredDuringScheduling" }}
88
    {{- range $index, $item := .podAntiAffinityTermLabelSelector }}
89
    - podAffinityTerm:
90
        labelSelector:
91
          matchExpressions:
92
          - key: {{ $item.key }}
93
            operator: {{ $item.operator }}
94
            {{- if $item.values }}
95
            values:
96
            {{- $vals := split "," $item.values }}
97
            {{- range $i, $v := $vals }}
98
            - {{ $v | quote }}
99
            {{- end }}
100
            {{- end }}
101
        topologyKey: {{ $item.topologyKey }}
102
      weight: 100
103
    {{- end }}
104
{{- end }}
105

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.