Skip to content

Commit

Permalink
Add more parameters to helm chart
Browse files Browse the repository at this point in the history
- 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 <gonzalesraul03@gmail.com>
  • Loading branch information
gonzalesraul committed Feb 3, 2023
1 parent 5ef6c8e commit aaa89f3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 18 deletions.
18 changes: 18 additions & 0 deletions charts/core-dump-handler/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,21 @@ Basically copied from https://github.com/bitnami/charts/blob/master/bitnami/comm
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}

{{- define "core-dump-handler.daemonset.container.volumeMounts" -}}
- name: host-volume
mountPath: {{ .Values.daemonset.hostDirectory }}
mountPropagation: Bidirectional
- name: core-volume
mountPath: {{ .Values.daemonset.coreDirectory }}
mountPropagation: Bidirectional
{{- if .Values.composer.coreEvents }}
- name: event-volume
mountPath: {{ .Values.daemonset.eventDirectory }}
mountPropagation: Bidirectional
{{- end }}
{{- if .Values.daemonset.mountContainerRuntimeEndpoint }}
- mountPath: {{ .Values.daemonset.hostContainerRuntimeEndpoint }}
name: container-runtime
{{- end }}
{{- end -}}
36 changes: 20 additions & 16 deletions charts/core-dump-handler/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ spec:
metadata:
labels:
name: {{ .Values.daemonset.label }}
annotations:
kubectl.kubernetes.io/default-container: "coredump-container"
spec:
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
Expand All @@ -28,22 +30,7 @@ spec:
cpu: {{ .Values.image.limit_cpu }}
securityContext:
privileged: true
volumeMounts:
- name: host-volume
mountPath: {{ .Values.daemonset.hostDirectory }}
mountPropagation: Bidirectional
- name: core-volume
mountPath: {{ .Values.daemonset.coreDirectory }}
mountPropagation: Bidirectional
{{- if .Values.composer.coreEvents }}
- name: event-volume
mountPath: {{ .Values.daemonset.eventDirectory }}
mountPropagation: Bidirectional
{{- end }}
{{- if .Values.daemonset.mountContainerRuntimeEndpoint }}
- mountPath: {{ .Values.daemonset.hostContainerRuntimeEndpoint }}
name: container-runtime
{{- end }}
volumeMounts: {{ include "core-dump-handler.daemonset.container.volumeMounts" . | nindent 10 }}
env:
- name: COMP_FILENAME_TEMPLATE
value: {{ .Values.composer.filenameTemplate | quote }}
Expand Down Expand Up @@ -114,11 +101,28 @@ spec:
{{- if .Values.daemonset.extraEnvVars }}
{{ include "core-dump-handler.tplvalues.render" ( dict "value" .Values.daemonset.extraEnvVars "context" $) | nindent 10 }}
{{- end }}
{{- with .Values.daemonset.envFrom }}
envFrom:
{{- toYaml . | nindent 10 }}
{{- end }}
command: ["/app/core-dump-agent"]
lifecycle:
preStop:
exec:
command: ["/app/core-dump-agent", "remove"]
{{- range .Values.daemonset.sidecarContainers }}
- {{ with . -}}
securityContext:
privileged: true
volumeMounts:
{{- include "core-dump-handler.daemonset.container.volumeMounts" $ | nindent 10 }}
{{- if .volumeMounts -}}
{{- toYaml .volumeMounts | nindent 10 }}
{{- end }}
{{- $_ := unset . "volumeMounts" -}}
{{- toYaml . | nindent 8 -}}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
12 changes: 11 additions & 1 deletion charts/core-dump-handler/values.minikube.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
storageClass: standard
image:
tag: latest
pullPolicy: Never
composer:
logLevel: "Debug"
coreEvents: true
daemonset:
mountContainerRuntimeEndpoint: true
hostContainerRuntimeEndpoint: "/var/run/cri-dockerd.sock"
crioEndpoint: "unix:///var/run/cri-dockerd.sock"
deployCrioConfig: true
includeCrioExe: true
sidecarContainers:
- name: simple-printer
image: alpine
command:
- /bin/sh
- -c
- |
apk --no-cache add inotify-tools
cd /var/mnt/core-dump-handler/events
inotifywait -mq -e create .| while read directory action file; do cat $file; done
8 changes: 7 additions & 1 deletion charts/core-dump-handler/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@
},
"extraEnvVars": {
"type": "string"
},
"envFrom": {
"type": "array"
},
"sidecarContainers": {
"type": "array"
}
},
"required": [
Expand Down Expand Up @@ -333,4 +339,4 @@
"title": "ServiceAccount"
}
}
}
}
2 changes: 2 additions & 0 deletions charts/core-dump-handler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ daemonset:
s3BucketName: XXX
s3Region: XXX
extraEnvVars: ""
envFrom: []
sidecarContainers: []

serviceAccount:
create: true
Expand Down

0 comments on commit aaa89f3

Please sign in to comment.