Skip to content

Commit aaa89f3

Browse files
committed
Add more parameters to helm chart
- Helm chart now supports injecting sidecar containers, adding envFrom instructions to read either configMaps as well as secrets. - Add sample sidecar to minikube values that prints the event file to stdout Signed-off-by: Raul Gonzales <[email protected]>
1 parent 5ef6c8e commit aaa89f3

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed

charts/core-dump-handler/templates/_helpers.tpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,21 @@ Basically copied from https://github.com/bitnami/charts/blob/master/bitnami/comm
7373
{{- tpl (.value | toYaml) .context }}
7474
{{- end }}
7575
{{- end -}}
76+
77+
{{- define "core-dump-handler.daemonset.container.volumeMounts" -}}
78+
- name: host-volume
79+
mountPath: {{ .Values.daemonset.hostDirectory }}
80+
mountPropagation: Bidirectional
81+
- name: core-volume
82+
mountPath: {{ .Values.daemonset.coreDirectory }}
83+
mountPropagation: Bidirectional
84+
{{- if .Values.composer.coreEvents }}
85+
- name: event-volume
86+
mountPath: {{ .Values.daemonset.eventDirectory }}
87+
mountPropagation: Bidirectional
88+
{{- end }}
89+
{{- if .Values.daemonset.mountContainerRuntimeEndpoint }}
90+
- mountPath: {{ .Values.daemonset.hostContainerRuntimeEndpoint }}
91+
name: container-runtime
92+
{{- end }}
93+
{{- end -}}

charts/core-dump-handler/templates/daemonset.yaml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ spec:
1010
metadata:
1111
labels:
1212
name: {{ .Values.daemonset.label }}
13+
annotations:
14+
kubectl.kubernetes.io/default-container: "coredump-container"
1315
spec:
1416
{{- with .Values.image.pullSecrets }}
1517
imagePullSecrets:
@@ -28,22 +30,7 @@ spec:
2830
cpu: {{ .Values.image.limit_cpu }}
2931
securityContext:
3032
privileged: true
31-
volumeMounts:
32-
- name: host-volume
33-
mountPath: {{ .Values.daemonset.hostDirectory }}
34-
mountPropagation: Bidirectional
35-
- name: core-volume
36-
mountPath: {{ .Values.daemonset.coreDirectory }}
37-
mountPropagation: Bidirectional
38-
{{- if .Values.composer.coreEvents }}
39-
- name: event-volume
40-
mountPath: {{ .Values.daemonset.eventDirectory }}
41-
mountPropagation: Bidirectional
42-
{{- end }}
43-
{{- if .Values.daemonset.mountContainerRuntimeEndpoint }}
44-
- mountPath: {{ .Values.daemonset.hostContainerRuntimeEndpoint }}
45-
name: container-runtime
46-
{{- end }}
33+
volumeMounts: {{ include "core-dump-handler.daemonset.container.volumeMounts" . | nindent 10 }}
4734
env:
4835
- name: COMP_FILENAME_TEMPLATE
4936
value: {{ .Values.composer.filenameTemplate | quote }}
@@ -114,11 +101,28 @@ spec:
114101
{{- if .Values.daemonset.extraEnvVars }}
115102
{{ include "core-dump-handler.tplvalues.render" ( dict "value" .Values.daemonset.extraEnvVars "context" $) | nindent 10 }}
116103
{{- end }}
104+
{{- with .Values.daemonset.envFrom }}
105+
envFrom:
106+
{{- toYaml . | nindent 10 }}
107+
{{- end }}
117108
command: ["/app/core-dump-agent"]
118109
lifecycle:
119110
preStop:
120111
exec:
121112
command: ["/app/core-dump-agent", "remove"]
113+
{{- range .Values.daemonset.sidecarContainers }}
114+
- {{ with . -}}
115+
securityContext:
116+
privileged: true
117+
volumeMounts:
118+
{{- include "core-dump-handler.daemonset.container.volumeMounts" $ | nindent 10 }}
119+
{{- if .volumeMounts -}}
120+
{{- toYaml .volumeMounts | nindent 10 }}
121+
{{- end }}
122+
{{- $_ := unset . "volumeMounts" -}}
123+
{{- toYaml . | nindent 8 -}}
124+
{{- end }}
125+
{{- end }}
122126
{{- with .Values.nodeSelector }}
123127
nodeSelector:
124128
{{- toYaml . | nindent 8 }}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
storageClass: standard
22
image:
33
tag: latest
4-
pullPolicy: Never
54
composer:
65
logLevel: "Debug"
6+
coreEvents: true
77
daemonset:
88
mountContainerRuntimeEndpoint: true
99
hostContainerRuntimeEndpoint: "/var/run/cri-dockerd.sock"
1010
crioEndpoint: "unix:///var/run/cri-dockerd.sock"
1111
deployCrioConfig: true
1212
includeCrioExe: true
13+
sidecarContainers:
14+
- name: simple-printer
15+
image: alpine
16+
command:
17+
- /bin/sh
18+
- -c
19+
- |
20+
apk --no-cache add inotify-tools
21+
cd /var/mnt/core-dump-handler/events
22+
inotifywait -mq -e create .| while read directory action file; do cat $file; done

charts/core-dump-handler/values.schema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@
262262
},
263263
"extraEnvVars": {
264264
"type": "string"
265+
},
266+
"envFrom": {
267+
"type": "array"
268+
},
269+
"sidecarContainers": {
270+
"type": "array"
265271
}
266272
},
267273
"required": [
@@ -333,4 +339,4 @@
333339
"title": "ServiceAccount"
334340
}
335341
}
336-
}
342+
}

charts/core-dump-handler/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ daemonset:
5555
s3BucketName: XXX
5656
s3Region: XXX
5757
extraEnvVars: ""
58+
envFrom: []
59+
sidecarContainers: []
5860

5961
serviceAccount:
6062
create: true

0 commit comments

Comments
 (0)