From 22cd62e90c973caf84b053db73eb405c34c3683c Mon Sep 17 00:00:00 2001 From: Lisa Parratt Date: Mon, 25 Jul 2022 15:25:05 +0100 Subject: [PATCH] Allow config files (e.g. whitelist) to be overridden from values. --- charts/krane/templates/_helpers.tpl | 11 ++++++++ charts/krane/templates/config.yaml | 35 ++++++++++++++++++++++++++ charts/krane/templates/deployment.yaml | 22 ++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 charts/krane/templates/config.yaml diff --git a/charts/krane/templates/_helpers.tpl b/charts/krane/templates/_helpers.tpl index c1a1e86..251dac8 100644 --- a/charts/krane/templates/_helpers.tpl +++ b/charts/krane/templates/_helpers.tpl @@ -73,3 +73,14 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Config labels +*/}} +{{- define "krane.configLabels" -}} +app.kubernetes.io/name: {{ include "krane.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/component: {{ include "krane.name" . }} +app.kubernetes.io/part-of: {{ include "krane.name" . }} +network/krane: "true" +{{- end }} diff --git a/charts/krane/templates/config.yaml b/charts/krane/templates/config.yaml new file mode 100644 index 0000000..be18cb8 --- /dev/null +++ b/charts/krane/templates/config.yaml @@ -0,0 +1,35 @@ +{{- if .Values.config }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "krane.fullname" . }} + labels: + {{- include "krane.labels" . | nindent 4 }} + {{- include "krane.configLabels" . | nindent 4 }} +data: + {{- if .Values.config.config }} + {{- with .Values.config.config }} + config.yaml: | + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + {{- if .Values.config.customrules }} + {{- with .Values.config.customrules }} + custom-rules.yaml: | + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + {{- if .Values.config.rules }} + {{- with .Values.config.rules }} + rules.yaml: | + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + {{- if .Values.config.whitelist }} + {{- with .Values.config.whitelist }} + whitelist.yaml: | + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/krane/templates/deployment.yaml b/charts/krane/templates/deployment.yaml index fb21050..f732672 100644 --- a/charts/krane/templates/deployment.yaml +++ b/charts/krane/templates/deployment.yaml @@ -137,6 +137,21 @@ spec: timeoutSeconds: 5 resources: {{- toYaml .Values.resources | nindent 12 }} + {{- if .Values.config }} + volumeMounts: + - name: config-volume + mountPath: /app/config/config.yaml + subPath: config.yaml + - name: config-volume + mountPath: /app/config/custom-rules.yaml + subPath: custom-rules.yaml + - name: config-volume + mountPath: /app/config/rules.yaml + subPath: rules.yaml + - name: config-volume + mountPath: /app/config/whitelist.yaml + subPath: whitelist.yaml + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -150,3 +165,10 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} restartPolicy: Always + {{- if .Values.config }} + volumes: + - name: config-volume + configMap: + name: {{ include "krane.fullname" . }} + {{- end }} +