From d6d9e61166a7e1505061cde4448f25ad73aabc2a Mon Sep 17 00:00:00 2001 From: Michael McLeroy Date: Tue, 23 May 2023 11:47:18 -0400 Subject: [PATCH 1/3] feat(fluentd): add image reference by digest Signed-off-by: Michael McLeroy --- charts/fluentd/Chart.yaml | 2 +- charts/fluentd/templates/_helpers.tpl | 7 +++++++ charts/fluentd/templates/_pod.tpl | 2 +- charts/fluentd/templates/tests/test-connection.yaml | 11 +++++++++-- charts/fluentd/values.yaml | 11 +++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/charts/fluentd/Chart.yaml b/charts/fluentd/Chart.yaml index e3a6fa6a..f19fa1a5 100644 --- a/charts/fluentd/Chart.yaml +++ b/charts/fluentd/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: fluentd description: A Helm chart for Kubernetes # type: application -version: 0.4.3 +version: 0.4.4 appVersion: v1.15.2 icon: https://www.fluentd.org/images/miscellany/fluentd-logo_2x.png home: https://www.fluentd.org/ diff --git a/charts/fluentd/templates/_helpers.tpl b/charts/fluentd/templates/_helpers.tpl index 72e878df..19b1020a 100644 --- a/charts/fluentd/templates/_helpers.tpl +++ b/charts/fluentd/templates/_helpers.tpl @@ -90,3 +90,10 @@ Name of the configMap used for additional configuration files; allows users to o {{ printf "%s-%s" "fluentd-config" ( include "fluentd.shortReleaseName" . ) }} {{- end -}} {{- end -}} + +{{/* +Fluentd image with tag/digest +*/}} +{{- define "fluentd.image" -}} +{{ .repository }}{{ ternary (printf ":%s" (toString .tag)) (printf "@%s" .digest) (empty .digest) }} +{{- end -}} \ No newline at end of file diff --git a/charts/fluentd/templates/_pod.tpl b/charts/fluentd/templates/_pod.tpl index f77fb2f8..dd732a43 100644 --- a/charts/fluentd/templates/_pod.tpl +++ b/charts/fluentd/templates/_pod.tpl @@ -21,7 +21,7 @@ containers: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 6 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default $defaultTag }}" + image: {{ include "fluentd.image" (merge .Values.image (dict "tag" (default $defaultTag .Values.image.tag))) }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.plugins }} command: diff --git a/charts/fluentd/templates/tests/test-connection.yaml b/charts/fluentd/templates/tests/test-connection.yaml index 7c0f8150..768899d4 100644 --- a/charts/fluentd/templates/tests/test-connection.yaml +++ b/charts/fluentd/templates/tests/test-connection.yaml @@ -1,3 +1,4 @@ +{{- if .Values.testFramework.enabled }} apiVersion: v1 kind: Pod metadata: @@ -9,7 +10,13 @@ metadata: spec: containers: - name: wget - image: busybox + image: {{ include "fluentd.image" .Values.testFramework.image }} + imagePullPolicy: {{ .Values.testFramework.image.pullPolicy }} command: ['wget'] - args: ['{{ include "fluentd.fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include "fluentd.fullname" . }}:24231/metrics'] + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 4 }} + {{- end }} restartPolicy: Never +{{- end }} \ No newline at end of file diff --git a/charts/fluentd/values.yaml b/charts/fluentd/values.yaml index b9ac8d98..db13cce2 100644 --- a/charts/fluentd/values.yaml +++ b/charts/fluentd/values.yaml @@ -11,6 +11,17 @@ image: repository: "fluent/fluentd-kubernetes-daemonset" pullPolicy: "IfNotPresent" tag: "" + # Digest overrides tag + digest: "" + +testFramework: + enabled: true + image: + repository: busybox + pullPolicy: Always + tag: latest + # Digest overrides tag + digest: "" ## Optional array of imagePullSecrets containing private registry credentials ## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ From e8112887a3dd9bf5a0c8f7157bec92d1c0237c4b Mon Sep 17 00:00:00 2001 From: Michael McLeroy Date: Wed, 31 May 2023 10:59:56 -0400 Subject: [PATCH 2/3] feat(fluentd): support both image tag and digest at same time Signed-off-by: Michael McLeroy --- charts/fluentd/templates/_helpers.tpl | 4 +++- charts/fluentd/values.yaml | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/fluentd/templates/_helpers.tpl b/charts/fluentd/templates/_helpers.tpl index 19b1020a..3b321b5f 100644 --- a/charts/fluentd/templates/_helpers.tpl +++ b/charts/fluentd/templates/_helpers.tpl @@ -95,5 +95,7 @@ Name of the configMap used for additional configuration files; allows users to o Fluentd image with tag/digest */}} {{- define "fluentd.image" -}} -{{ .repository }}{{ ternary (printf ":%s" (toString .tag)) (printf "@%s" .digest) (empty .digest) }} +{{- $tag := ternary "" (printf ":%s" (toString .tag)) (or (empty .tag) (eq "-" (toString .tag))) -}} +{{- $digest := ternary "" (printf "@%s" .digest) (empty .digest) -}} +{{- printf "%s%s%s" .repository $tag $digest -}} {{- end -}} \ No newline at end of file diff --git a/charts/fluentd/values.yaml b/charts/fluentd/values.yaml index db13cce2..0db3f034 100644 --- a/charts/fluentd/values.yaml +++ b/charts/fluentd/values.yaml @@ -10,8 +10,7 @@ kind: "DaemonSet" image: repository: "fluent/fluentd-kubernetes-daemonset" pullPolicy: "IfNotPresent" - tag: "" - # Digest overrides tag + tag: "" # Set to "-" to not use the default value digest: "" testFramework: @@ -20,7 +19,6 @@ testFramework: repository: busybox pullPolicy: Always tag: latest - # Digest overrides tag digest: "" ## Optional array of imagePullSecrets containing private registry credentials From ca8249631f9f678f89846e4344162431f0740188 Mon Sep 17 00:00:00 2001 From: Michael McLeroy Date: Thu, 1 Jun 2023 15:44:54 -0400 Subject: [PATCH 3/3] fix(fluentd): spacing before comment Signed-off-by: Michael McLeroy --- charts/fluentd/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/fluentd/values.yaml b/charts/fluentd/values.yaml index 0db3f034..f34ac5ec 100644 --- a/charts/fluentd/values.yaml +++ b/charts/fluentd/values.yaml @@ -10,7 +10,7 @@ kind: "DaemonSet" image: repository: "fluent/fluentd-kubernetes-daemonset" pullPolicy: "IfNotPresent" - tag: "" # Set to "-" to not use the default value + tag: "" # Set to "-" to not use the default value digest: "" testFramework: