Skip to content

Commit b88ba72

Browse files
authored
feat: add tolerations and affinity in the global values (#476)
Signed-off-by: José Guilherme Vanz <[email protected]>
1 parent 05a6207 commit b88ba72

File tree

7 files changed

+139
-31
lines changed

7 files changed

+139
-31
lines changed

charts/kubewarden-controller/templates/audit-scanner.yaml

+10-12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ spec:
3535
items:
3636
- key: policy-server-root-ca-pem
3737
path: "policy-server-root-ca-pem"
38+
{{- if .Values.global.affinity }}
39+
affinity: {{ .Values.global.affinity | toYaml | nindent 14 }}
40+
{{- end }}
41+
{{- if .Values.global.tolerations }}
42+
tolerations: {{ .Values.global.tolerations | toYaml | nindent 14 }}
43+
{{- end }}
44+
{{- with .Values.nodeSelector }}
45+
nodeSelector:
46+
{{- toYaml . | nindent 14 }}
47+
{{- end }}
3848
containers:
3949
- name: audit-scanner
4050
image: '{{ template "system_default_registry" . }}{{ .Values.auditScanner.image.repository }}:{{ .Values.auditScanner.image.tag }}'
@@ -49,18 +59,6 @@ spec:
4959
securityContext:
5060
{{- toYaml . | nindent 14 }}
5161
{{- end }}
52-
{{- with .Values.nodeSelector }}
53-
nodeSelector:
54-
{{- toYaml . | nindent 14 }}
55-
{{- end }}
56-
{{- with .Values.affinity }}
57-
affinity:
58-
{{- toYaml . | nindent 14 }}
59-
{{- end }}
60-
{{- with .Values.tolerations }}
61-
tolerations:
62-
{{- toYaml . | nindent 14 }}
63-
{{- end }}
6462
{{- if and .Values.resources .Values.resources.auditScanner }}
6563
resources:
6664
{{ toYaml .Values.resources.auditScanner | indent 14 }}

charts/kubewarden-controller/templates/deployment.yaml

+10-12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ spec:
3030
{{- include "imagePullSecrets" .Values.imagePullSecrets | nindent 8 }}
3131
{{- end }}
3232
serviceAccountName: {{ include "kubewarden-controller.serviceAccountName" . }}
33+
{{- if .Values.global.affinity }}
34+
affinity: {{ .Values.global.affinity | toYaml | nindent 8 }}
35+
{{- end }}
36+
{{- if .Values.global.tolerations }}
37+
tolerations: {{ .Values.global.tolerations | toYaml | nindent 8 }}
38+
{{- end }}
39+
{{- with .Values.nodeSelector }}
40+
nodeSelector:
41+
{{- toYaml . | nindent 8 }}
42+
{{- end }}
3343
containers:
3444
- name: manager
3545
args:
@@ -93,15 +103,3 @@ spec:
93103
{{ toYaml .Values.podSecurityContext | indent 8 }}
94104
{{- end }}
95105
terminationGracePeriodSeconds: 10
96-
{{- with .Values.nodeSelector }}
97-
nodeSelector:
98-
{{- toYaml . | nindent 8 }}
99-
{{- end }}
100-
{{- with .Values.affinity }}
101-
affinity:
102-
{{- toYaml . | nindent 8 }}
103-
{{- end }}
104-
{{- with .Values.tolerations }}
105-
tolerations:
106-
{{- toYaml . | nindent 8 }}
107-
{{- end }}

charts/kubewarden-controller/values.yaml

+55-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,61 @@
33
# by more than one chart and they ideally need to match during the
44
# installation of the charts consuming this values.
55
global:
6+
# affinity:
7+
# podAffinity:
8+
# requiredDuringSchedulingIgnoredDuringExecution:
9+
# - labelSelector:
10+
# matchExpressions:
11+
# - key: security
12+
# operator: In
13+
# values:
14+
# - S1
15+
# topologyKey: topology.kubernetes.io/zone
16+
# podAntiAffinity:
17+
# preferredDuringSchedulingIgnoredDuringExecution:
18+
# - weight: 100
19+
# podAffinityTerm:
20+
# labelSelector:
21+
# matchExpressions:
22+
# - key: security
23+
# operator: In
24+
# values:
25+
# - S2
26+
# topologyKey: topology.kubernetes.io/zone
27+
# nodeAffinity:
28+
# requiredDuringSchedulingIgnoredDuringExecution:
29+
# nodeSelectorTerms:
30+
# - matchExpressions:
31+
# - key: kubernetes.io/os
32+
# operator: In
33+
# values:
34+
# - linux
35+
# preferredDuringSchedulingIgnoredDuringExecution:
36+
# - weight: 1
37+
# preference:
38+
# matchExpressions:
39+
# - key: label-1
40+
# operator: In
41+
# values:
42+
# - key-1
43+
# - weight: 50
44+
# preference:
45+
# matchExpressions:
46+
# - key: label-2
47+
# operator: In
48+
# values:
49+
# - key-2
50+
affinity: {}
51+
# tolerations:
52+
# - key: "key1"
53+
# operator: "Equal"
54+
# value: "value1"
55+
# effect: "NoSchedule"
56+
# - key: "key1"
57+
# operator: "Equal"
58+
# value: "value1"
59+
# effect: "NoExecute"
60+
tolerations: []
661
cattle:
762
systemDefaultRegistry: ghcr.io
863
skipNamespaces:
@@ -111,8 +166,6 @@ preDeleteJob:
111166
# kubewarden-controller deployment settings:
112167
podAnnotations: {}
113168
nodeSelector: {}
114-
tolerations: []
115-
affinity: {}
116169
tls:
117170
# source options:
118171
# - "cert-manager-self-signed": Scaffold cert-manager integration, and create

charts/kubewarden-defaults/templates/_helpers.tpl

-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,3 @@ namespaceSelector:
7676
{{- printf "%s/" .Values.global.cattle.systemDefaultRegistry -}}
7777
{{- end -}}
7878
{{- end -}}
79-

charts/kubewarden-defaults/templates/policyserver-default.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ spec:
2020
{{- if .Values.policyServer.maxUnavailable }}
2121
maxUnavailable: {{ .Values.policyServer.maxUnavailable }}
2222
{{- end }}
23-
{{- if .Values.policyServer.affinity }}
24-
affinity: {{ .Values.policyServer.affinity | toYaml | nindent 4 }}
23+
{{- if .Values.global.affinity }}
24+
affinity: {{ .Values.global.affinity | toYaml | nindent 4 }}
25+
{{- end }}
26+
{{- if .Values.global.tolerations }}
27+
tolerations: {{ .Values.global.tolerations | toYaml | nindent 4 }}
2528
{{- end }}
2629
{{- if .Values.policyServer.limits }}
2730
limits: {{ .Values.policyServer.limits | toYaml | nindent 4 }}

charts/kubewarden-defaults/values.yaml

+55-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,61 @@
33
# by more than one chart and they ideally need to match during the
44
# installation of the charts consuming this values.
55
global:
6+
# affinity:
7+
# podAffinity:
8+
# requiredDuringSchedulingIgnoredDuringExecution:
9+
# - labelSelector:
10+
# matchExpressions:
11+
# - key: security
12+
# operator: In
13+
# values:
14+
# - S1
15+
# topologyKey: topology.kubernetes.io/zone
16+
# podAntiAffinity:
17+
# preferredDuringSchedulingIgnoredDuringExecution:
18+
# - weight: 100
19+
# podAffinityTerm:
20+
# labelSelector:
21+
# matchExpressions:
22+
# - key: security
23+
# operator: In
24+
# values:
25+
# - S2
26+
# topologyKey: topology.kubernetes.io/zone
27+
# nodeAffinity:
28+
# requiredDuringSchedulingIgnoredDuringExecution:
29+
# nodeSelectorTerms:
30+
# - matchExpressions:
31+
# - key: kubernetes.io/os
32+
# operator: In
33+
# values:
34+
# - linux
35+
# preferredDuringSchedulingIgnoredDuringExecution:
36+
# - weight: 1
37+
# preference:
38+
# matchExpressions:
39+
# - key: label-1
40+
# operator: In
41+
# values:
42+
# - key-1
43+
# - weight: 50
44+
# preference:
45+
# matchExpressions:
46+
# - key: label-2
47+
# operator: In
48+
# values:
49+
# - key-2
50+
affinity: {}
51+
# tolerations:
52+
# - key: "key1"
53+
# operator: "Equal"
54+
# value: "value1"
55+
# effect: "NoSchedule"
56+
# - key: "key1"
57+
# operator: "Equal"
58+
# value: "value1"
59+
# effect: "NoExecute"
60+
tolerations: []
661
cattle:
762
systemDefaultRegistry: ghcr.io
863
skipNamespaces:
@@ -113,8 +168,6 @@ policyServer:
113168
# certs:
114169
# - "cert4"
115170
sourceAuthorities: {}
116-
# affinity for pods of the default PolicyServer
117-
affinity: {}
118171
# limits and requests, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
119172
limits: {}
120173
requests: {}

common-values.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# by more than one chart and they ideally need to match during the
33
# installation of the charts consuming this values.
44
global:
5+
affinity: {}
6+
tolerations: []
57
cattle:
68
systemDefaultRegistry: ghcr.io
79
skipNamespaces:
@@ -47,3 +49,5 @@ global:
4749
default:
4850
name: default
4951
enabled: true
52+
affinity: {}
53+
tolerations: []

0 commit comments

Comments
 (0)