Skip to content

Commit 62d91f9

Browse files
(helm/v2alpha): allow manager values to be customized properly
This update makes sure the manager Helm chart uses values taken from the Kustomize deployment files (like install.yaml), instead of using hardcoded settings. The controller specs are now read from those inputs and passed into Helm values so the chart renders correctly and matches the deployment. PS:Follow up of helm-chart v2alpha introduction
1 parent 045b3e1 commit 62d91f9

File tree

14 files changed

+787
-139
lines changed

14 files changed

+787
-139
lines changed

docs/book/src/cronjob-tutorial/testdata/project/dist/chart/templates/manager/manager.yaml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ spec:
2323
spec:
2424
containers:
2525
- args:
26+
{{- if .Values.metrics.enable }}
2627
- --metrics-bind-address=:8443
27-
- --leader-elect
28+
{{- else }}
29+
# Bind to :0 to disable the controller-runtime managed metrics server
30+
- --metrics-bind-address=:0
31+
{{- end }}
2832
- --health-probe-bind-address=:8081
33+
{{- range .Values.controllerManager.args }}
34+
- {{ . }}
35+
{{- end }}
2936
{{- if and .Values.certManager.enable .Values.metrics.enable }}
3037
- --metrics-cert-path=/tmp/k8s-metrics-server/metrics-certs
3138
{{- end }}
@@ -35,6 +42,7 @@ spec:
3542
command:
3643
- /manager
3744
image: "{{ .Values.controllerManager.image.repository }}:{{ .Values.controllerManager.image.tag }}"
45+
imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }}
3846
livenessProbe:
3947
httpGet:
4048
path: /healthz
@@ -53,18 +61,17 @@ spec:
5361
initialDelaySeconds: 5
5462
periodSeconds: 10
5563
resources:
56-
limits:
57-
cpu: 500m
58-
memory: 128Mi
59-
requests:
60-
cpu: 10m
61-
memory: 64Mi
64+
{{- if .Values.controllerManager.resources }}
65+
{{- toYaml .Values.controllerManager.resources | nindent 20 }}
66+
{{- else }}
67+
{}
68+
{{- end }}
6269
securityContext:
63-
allowPrivilegeEscalation: false
64-
capabilities:
65-
drop:
66-
- ALL
67-
readOnlyRootFilesystem: true
70+
{{- if .Values.controllerManager.securityContext }}
71+
{{- toYaml .Values.controllerManager.securityContext | nindent 20 }}
72+
{{- else }}
73+
{}
74+
{{- end }}
6875
volumeMounts:
6976
{{- if and .Values.certManager.enable .Values.metrics.enable }}
7077
- mountPath: /tmp/k8s-metrics-server/metrics-certs
@@ -77,9 +84,11 @@ spec:
7784
readOnly: true
7885
{{- end }}
7986
securityContext:
80-
runAsNonRoot: true
81-
seccompProfile:
82-
type: RuntimeDefault
87+
{{- if .Values.controllerManager.podSecurityContext }}
88+
{{- toYaml .Values.controllerManager.podSecurityContext | nindent 14 }}
89+
{{- else }}
90+
{}
91+
{{- end }}
8392
serviceAccountName: project-controller-manager
8493
terminationGracePeriodSeconds: 10
8594
volumes:

docs/book/src/cronjob-tutorial/testdata/project/dist/chart/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ controllerManager:
77
tag: latest
88
pullPolicy: IfNotPresent
99

10+
# Arguments
11+
args:
12+
- --leader-elect
13+
1014
# Environment variables
1115
env: []
1216

docs/book/src/getting-started/testdata/project/dist/chart/templates/manager/manager.yaml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ spec:
2323
spec:
2424
containers:
2525
- args:
26+
{{- if .Values.metrics.enable }}
2627
- --metrics-bind-address=:8443
27-
- --leader-elect
28+
{{- else }}
29+
# Bind to :0 to disable the controller-runtime managed metrics server
30+
- --metrics-bind-address=:0
31+
{{- end }}
2832
- --health-probe-bind-address=:8081
33+
{{- range .Values.controllerManager.args }}
34+
- {{ . }}
35+
{{- end }}
2936
command:
3037
- /manager
3138
image: "{{ .Values.controllerManager.image.repository }}:{{ .Values.controllerManager.image.tag }}"
39+
imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }}
3240
livenessProbe:
3341
httpGet:
3442
path: /healthz
@@ -44,23 +52,24 @@ spec:
4452
initialDelaySeconds: 5
4553
periodSeconds: 10
4654
resources:
47-
limits:
48-
cpu: 500m
49-
memory: 128Mi
50-
requests:
51-
cpu: 10m
52-
memory: 64Mi
55+
{{- if .Values.controllerManager.resources }}
56+
{{- toYaml .Values.controllerManager.resources | nindent 20 }}
57+
{{- else }}
58+
{}
59+
{{- end }}
5360
securityContext:
54-
allowPrivilegeEscalation: false
55-
capabilities:
56-
drop:
57-
- ALL
58-
readOnlyRootFilesystem: true
61+
{{- if .Values.controllerManager.securityContext }}
62+
{{- toYaml .Values.controllerManager.securityContext | nindent 20 }}
63+
{{- else }}
64+
{}
65+
{{- end }}
5966
volumeMounts: []
6067
securityContext:
61-
runAsNonRoot: true
62-
seccompProfile:
63-
type: RuntimeDefault
68+
{{- if .Values.controllerManager.podSecurityContext }}
69+
{{- toYaml .Values.controllerManager.podSecurityContext | nindent 14 }}
70+
{{- else }}
71+
{}
72+
{{- end }}
6473
serviceAccountName: project-controller-manager
6574
terminationGracePeriodSeconds: 10
6675
volumes: []

docs/book/src/getting-started/testdata/project/dist/chart/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ controllerManager:
77
tag: latest
88
pullPolicy: IfNotPresent
99

10+
# Arguments
11+
args:
12+
- --leader-elect
13+
1014
# Environment variables
1115
env: []
1216

docs/book/src/multiversion-tutorial/testdata/project/dist/chart/templates/manager/manager.yaml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ spec:
2323
spec:
2424
containers:
2525
- args:
26+
{{- if .Values.metrics.enable }}
2627
- --metrics-bind-address=:8443
27-
- --leader-elect
28+
{{- else }}
29+
# Bind to :0 to disable the controller-runtime managed metrics server
30+
- --metrics-bind-address=:0
31+
{{- end }}
2832
- --health-probe-bind-address=:8081
33+
{{- range .Values.controllerManager.args }}
34+
- {{ . }}
35+
{{- end }}
2936
{{- if and .Values.certManager.enable .Values.metrics.enable }}
3037
- --metrics-cert-path=/tmp/k8s-metrics-server/metrics-certs
3138
{{- end }}
@@ -35,6 +42,7 @@ spec:
3542
command:
3643
- /manager
3744
image: "{{ .Values.controllerManager.image.repository }}:{{ .Values.controllerManager.image.tag }}"
45+
imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }}
3846
livenessProbe:
3947
httpGet:
4048
path: /healthz
@@ -53,18 +61,17 @@ spec:
5361
initialDelaySeconds: 5
5462
periodSeconds: 10
5563
resources:
56-
limits:
57-
cpu: 500m
58-
memory: 128Mi
59-
requests:
60-
cpu: 10m
61-
memory: 64Mi
64+
{{- if .Values.controllerManager.resources }}
65+
{{- toYaml .Values.controllerManager.resources | nindent 20 }}
66+
{{- else }}
67+
{}
68+
{{- end }}
6269
securityContext:
63-
allowPrivilegeEscalation: false
64-
capabilities:
65-
drop:
66-
- ALL
67-
readOnlyRootFilesystem: true
70+
{{- if .Values.controllerManager.securityContext }}
71+
{{- toYaml .Values.controllerManager.securityContext | nindent 20 }}
72+
{{- else }}
73+
{}
74+
{{- end }}
6875
volumeMounts:
6976
{{- if and .Values.certManager.enable .Values.metrics.enable }}
7077
- mountPath: /tmp/k8s-metrics-server/metrics-certs
@@ -77,9 +84,11 @@ spec:
7784
readOnly: true
7885
{{- end }}
7986
securityContext:
80-
runAsNonRoot: true
81-
seccompProfile:
82-
type: RuntimeDefault
87+
{{- if .Values.controllerManager.podSecurityContext }}
88+
{{- toYaml .Values.controllerManager.podSecurityContext | nindent 14 }}
89+
{{- else }}
90+
{}
91+
{{- end }}
8392
serviceAccountName: project-controller-manager
8493
terminationGracePeriodSeconds: 10
8594
volumes:

docs/book/src/multiversion-tutorial/testdata/project/dist/chart/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ controllerManager:
77
tag: latest
88
pullPolicy: IfNotPresent
99

10+
# Arguments
11+
args:
12+
- --leader-elect
13+
1014
# Environment variables
1115
env: []
1216

0 commit comments

Comments
 (0)