From ee156319003c7f7069352c38c0163a9016d09eee Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Mon, 12 Apr 2021 09:28:53 +0200 Subject: [PATCH 1/2] Generic sidecar support --- charts/onechart/templates/deployment.yaml | 12 +++++++----- ...idecar_test.yaml => deployment_sidecar_test.yaml} | 6 ++++-- charts/onechart/values.yaml | 6 ------ 3 files changed, 11 insertions(+), 13 deletions(-) rename charts/onechart/tests/{deployment_debug_sidecar_test.yaml => deployment_sidecar_test.yaml} (63%) diff --git a/charts/onechart/templates/deployment.yaml b/charts/onechart/templates/deployment.yaml index 506f55d..14cf35d 100644 --- a/charts/onechart/templates/deployment.yaml +++ b/charts/onechart/templates/deployment.yaml @@ -90,14 +90,16 @@ spec: {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} - {{- if .Values.debugSidecarEnabled }} - - name: {{ template "robustName" .Release.Name }}-debug + {{- if .Values.sidecar }} + - name: {{ template "robustName" .Release.Name }}-sidecar securityContext: *securityContext - image: {{ .Values.debugSidecar.image }} + image: {{ .Values.sidecar.repository }}:{{ .Values.sidecar.tag }} + {{- if .Values.sidecar.command }} command: - - {{ .Values.debugSidecar.shell }} + - {{ .Values.sidecar.shell }} - -c - - {{ .Values.debugSidecar.command | quote }} + - {{ .Values.sidecar.command | quote }} + {{- end }} {{- if or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets }} envFrom: *envFrom {{- end }} diff --git a/charts/onechart/tests/deployment_debug_sidecar_test.yaml b/charts/onechart/tests/deployment_sidecar_test.yaml similarity index 63% rename from charts/onechart/tests/deployment_debug_sidecar_test.yaml rename to charts/onechart/tests/deployment_sidecar_test.yaml index 09eec07..a49f5ad 100644 --- a/charts/onechart/tests/deployment_debug_sidecar_test.yaml +++ b/charts/onechart/tests/deployment_sidecar_test.yaml @@ -3,9 +3,11 @@ templates: - deployment.yaml - configmap.yaml tests: - - it: Should add a debug sidecar + - it: Should inject a sidecar if one is specified set: - debugSidecarEnabled: true + sidecar: + repository: debian + tag: stable-slim asserts: - equal: path: spec.template.spec.containers[1].image diff --git a/charts/onechart/values.yaml b/charts/onechart/values.yaml index a509bbb..d76547d 100644 --- a/charts/onechart/values.yaml +++ b/charts/onechart/values.yaml @@ -44,12 +44,6 @@ secretEnabled: false shell: "/bin/sh" -debugSidecarEnabled: false -debugSidecar: - image: debian:stable-slim - shell: "/bin/bash" - command: "while true; do sleep 30; done;" - podDisruptionBudgetEnabled: true spreadAcrossNodes: false From 28918e3359af8d249e051c34e6614e92257df879 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Wed, 28 Apr 2021 09:55:29 +0200 Subject: [PATCH 2/2] Debug sidecar test --- charts/onechart/tests/deployment_sidecar_test.yaml | 11 +++++++++++ values.yaml | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/charts/onechart/tests/deployment_sidecar_test.yaml b/charts/onechart/tests/deployment_sidecar_test.yaml index a49f5ad..e4c75f6 100644 --- a/charts/onechart/tests/deployment_sidecar_test.yaml +++ b/charts/onechart/tests/deployment_sidecar_test.yaml @@ -12,3 +12,14 @@ tests: - equal: path: spec.template.spec.containers[1].image value: debian:stable-slim + - it: Should inject a debug sidecar with shell and command specified + set: + sidecar: + repository: debian + tag: stable-slim + shell: "/bin/bash" + command: "while true; do sleep 30; done;" + asserts: + - equal: + path: spec.template.spec.containers[1].image + value: debian:stable-slim \ No newline at end of file diff --git a/values.yaml b/values.yaml index aa3061e..51e5ad0 100644 --- a/values.yaml +++ b/values.yaml @@ -9,3 +9,9 @@ fileSecrets: a multiline secret + +sidecar: + repository: debian + tag: stable-slim + shell: "/bin/bash" + command: "while true; do sleep 30; done;"