From a1fdf8930bef1aa1597458fc915b6f73b7577662 Mon Sep 17 00:00:00 2001 From: Michael McLeroy Date: Tue, 23 May 2023 11:30:57 -0400 Subject: [PATCH 1/2] feat(fluent-operator): add image reference by digest Signed-off-by: Michael McLeroy --- charts/fluent-operator/Chart.yaml | 2 +- charts/fluent-operator/templates/_helpers.tpl | 7 +++++++ .../templates/fluent-operator-deployment.yaml | 8 ++++---- charts/fluent-operator/templates/fluentbit-fluentBit.yaml | 2 +- .../templates/fluentbit-fluentbit-edge.yaml | 2 +- charts/fluent-operator/templates/fluentd-fluentd.yaml | 2 +- charts/fluent-operator/values.yaml | 8 ++++++++ 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/charts/fluent-operator/Chart.yaml b/charts/fluent-operator/Chart.yaml index 7c2d43ef..abdb9144 100644 --- a/charts/fluent-operator/Chart.yaml +++ b/charts/fluent-operator/Chart.yaml @@ -6,7 +6,7 @@ keywords: - fluent-bit - fluentd - operator -version: 2.2.0 +version: 2.2.1 appVersion: 2.2.0 icon: https://raw.githubusercontent.com/fluent/fluent-operator/master/docs/images/fluent-operator-icon.svg home: https://www.fluentd.org/ diff --git a/charts/fluent-operator/templates/_helpers.tpl b/charts/fluent-operator/templates/_helpers.tpl index 7805f0ea..fa08d490 100644 --- a/charts/fluent-operator/templates/_helpers.tpl +++ b/charts/fluent-operator/templates/_helpers.tpl @@ -61,3 +61,10 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Fluentbit operator image with tag/digest +*/}} +{{- define "fluentbit-operator.image" -}} +{{ .repository }}{{ ternary (printf ":%s" (toString .tag)) (printf "@%s" .digest) (empty .digest) }} +{{- end -}} \ No newline at end of file diff --git a/charts/fluent-operator/templates/fluent-operator-deployment.yaml b/charts/fluent-operator/templates/fluent-operator-deployment.yaml index 470ac3d4..ee67d307 100644 --- a/charts/fluent-operator/templates/fluent-operator-deployment.yaml +++ b/charts/fluent-operator/templates/fluent-operator-deployment.yaml @@ -34,7 +34,7 @@ spec: path: /var/run/docker.sock initContainers: - name: setenv - image: {{ .Values.operator.initcontainer.repository }}:{{ .Values.operator.initcontainer.tag }} + image: {{ include "fluentbit-operator.image" .Values.operator.initcontainer }} command: - /bin/sh - '-c' @@ -52,7 +52,7 @@ spec: emptyDir: {} initContainers: - name: setenv - image: {{ .Values.operator.initcontainer.repository }}:{{ .Values.operator.initcontainer.tag }} + image: {{ .Values.operator.initcontainer.repository }}{{ ternary (printf ":%s" (toString .Values.operator.initcontainer.tag)) (printf "@%s" .Values.operator.initcontainer.digest) (empty .Values.operator.initcontainer.digest) }} command: - /bin/sh - '-c' @@ -67,7 +67,7 @@ spec: emptyDir: {} initContainers: - name: setenv - image: {{ .Values.operator.initcontainer.repository }}:{{ .Values.operator.initcontainer.tag }} + image: {{ .Values.operator.initcontainer.repository }}{{ ternary (printf ":%s" (toString .Values.operator.initcontainer.tag)) (printf "@%s" .Values.operator.initcontainer.digest) (empty .Values.operator.initcontainer.digest) }} command: - /bin/sh - '-c' @@ -79,7 +79,7 @@ spec: {{- end }} containers: - name: fluent-operator - image: {{ .Values.operator.container.repository }}:{{ .Values.operator.container.tag }} + image: {{ .Values.operator.container.repository }}{{ ternary (printf ":%s" (toString .Values.operator.container.tag)) (printf "@%s" .Values.operator.container.digest) (empty .Values.operator.container.digest) }} resources: {{- toYaml .Values.operator.resources | nindent 10 }} env: diff --git a/charts/fluent-operator/templates/fluentbit-fluentBit.yaml b/charts/fluent-operator/templates/fluentbit-fluentBit.yaml index 10d2b19e..e3490a38 100644 --- a/charts/fluent-operator/templates/fluentbit-fluentBit.yaml +++ b/charts/fluent-operator/templates/fluentbit-fluentBit.yaml @@ -7,7 +7,7 @@ metadata: labels: app.kubernetes.io/name: fluent-bit spec: - image: {{ .Values.fluentbit.image.repository }}:{{ .Values.fluentbit.image.tag }} + image: {{ include "fluentbit-operator.image" .Values.fluentbit.image }} {{- if .Values.fluentbit.imagePullSecrets }} imagePullSecrets: {{ toYaml .Values.fluentbit.imagePullSecrets | indent 4 }} diff --git a/charts/fluent-operator/templates/fluentbit-fluentbit-edge.yaml b/charts/fluent-operator/templates/fluentbit-fluentbit-edge.yaml index 897bffd9..e206cc1b 100644 --- a/charts/fluent-operator/templates/fluentbit-fluentbit-edge.yaml +++ b/charts/fluent-operator/templates/fluentbit-fluentbit-edge.yaml @@ -7,7 +7,7 @@ metadata: labels: app.kubernetes.io/name: fluent-bit spec: - image: {{ .Values.fluentbit.image.repository }}:{{ .Values.fluentbit.image.tag }} + image: {{ include "fluentbit-operator.image" .Values.fluentbit.image }} positionDB: hostPath: path: /var/lib/fluent-bit/ diff --git a/charts/fluent-operator/templates/fluentd-fluentd.yaml b/charts/fluent-operator/templates/fluentd-fluentd.yaml index 6db6b117..dbcc920d 100644 --- a/charts/fluent-operator/templates/fluentd-fluentd.yaml +++ b/charts/fluent-operator/templates/fluentd-fluentd.yaml @@ -12,7 +12,7 @@ spec: bind: 0.0.0.0 port: {{ .Values.fluentd.port }} replicas: {{ .Values.fluentd.replicas }} - image: {{ .Values.fluentd.image.repository }}:{{ .Values.fluentd.image.tag }} + image: {{ include "fluentbit-operator.image" .Values.fluentd.image }} resources: {{- toYaml .Values.fluentd.resources | nindent 4 }} fluentdCfgSelector: diff --git a/charts/fluent-operator/values.yaml b/charts/fluent-operator/values.yaml index 10c5a1ae..f606da17 100644 --- a/charts/fluent-operator/values.yaml +++ b/charts/fluent-operator/values.yaml @@ -14,9 +14,13 @@ operator: initcontainer: repository: "docker" tag: "20.10" + # Digest overrides tag + digest: "" container: repository: "kubesphere/fluent-operator" tag: "v2.2.0" + # Digest overrides tag + digest: "" # FluentBit operator resources. Usually user needn't to adjust these. resources: limits: @@ -54,6 +58,8 @@ fluentbit: image: repository: "kubesphere/fluent-bit" tag: "v2.0.11" + # Digest overrides tag + digest: "" # fluentbit resources. If you do want to specify resources, adjust them as necessary # You can adjust it based on the log volume. resources: @@ -197,6 +203,8 @@ fluentd: image: repository: "kubesphere/fluentd" tag: "v1.15.3" + # Digest overrides tag + digest: "" replicas: 1 forward: port: 24224 From de8cbbfbdf9e66ea92c6589d46af32f95befd593 Mon Sep 17 00:00:00 2001 From: Michael McLeroy Date: Thu, 1 Jun 2023 16:02:53 -0400 Subject: [PATCH 2/2] feat(fluentbit-operator): support both image tag and digest together Signed-off-by: Michael McLeroy --- charts/fluent-operator/templates/_helpers.tpl | 4 +++- .../templates/fluent-operator-deployment.yaml | 6 +++--- charts/fluent-operator/values.yaml | 4 ---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/charts/fluent-operator/templates/_helpers.tpl b/charts/fluent-operator/templates/_helpers.tpl index fa08d490..f3aea734 100644 --- a/charts/fluent-operator/templates/_helpers.tpl +++ b/charts/fluent-operator/templates/_helpers.tpl @@ -66,5 +66,7 @@ Create the name of the service account to use Fluentbit operator image with tag/digest */}} {{- define "fluentbit-operator.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/fluent-operator/templates/fluent-operator-deployment.yaml b/charts/fluent-operator/templates/fluent-operator-deployment.yaml index ee67d307..abac21b4 100644 --- a/charts/fluent-operator/templates/fluent-operator-deployment.yaml +++ b/charts/fluent-operator/templates/fluent-operator-deployment.yaml @@ -52,7 +52,7 @@ spec: emptyDir: {} initContainers: - name: setenv - image: {{ .Values.operator.initcontainer.repository }}{{ ternary (printf ":%s" (toString .Values.operator.initcontainer.tag)) (printf "@%s" .Values.operator.initcontainer.digest) (empty .Values.operator.initcontainer.digest) }} + image: {{ include "fluentbit-operator.image" .Values.operator.initcontainer }} command: - /bin/sh - '-c' @@ -67,7 +67,7 @@ spec: emptyDir: {} initContainers: - name: setenv - image: {{ .Values.operator.initcontainer.repository }}{{ ternary (printf ":%s" (toString .Values.operator.initcontainer.tag)) (printf "@%s" .Values.operator.initcontainer.digest) (empty .Values.operator.initcontainer.digest) }} + image: {{ include "fluentbit-operator.image" .Values.operator.initcontainer }} command: - /bin/sh - '-c' @@ -79,7 +79,7 @@ spec: {{- end }} containers: - name: fluent-operator - image: {{ .Values.operator.container.repository }}{{ ternary (printf ":%s" (toString .Values.operator.container.tag)) (printf "@%s" .Values.operator.container.digest) (empty .Values.operator.container.digest) }} + image: {{ include "fluentbit-operator.image" .Values.operator.container }} resources: {{- toYaml .Values.operator.resources | nindent 10 }} env: diff --git a/charts/fluent-operator/values.yaml b/charts/fluent-operator/values.yaml index f606da17..5a937be5 100644 --- a/charts/fluent-operator/values.yaml +++ b/charts/fluent-operator/values.yaml @@ -14,12 +14,10 @@ operator: initcontainer: repository: "docker" tag: "20.10" - # Digest overrides tag digest: "" container: repository: "kubesphere/fluent-operator" tag: "v2.2.0" - # Digest overrides tag digest: "" # FluentBit operator resources. Usually user needn't to adjust these. resources: @@ -58,7 +56,6 @@ fluentbit: image: repository: "kubesphere/fluent-bit" tag: "v2.0.11" - # Digest overrides tag digest: "" # fluentbit resources. If you do want to specify resources, adjust them as necessary # You can adjust it based on the log volume. @@ -203,7 +200,6 @@ fluentd: image: repository: "kubesphere/fluentd" tag: "v1.15.3" - # Digest overrides tag digest: "" replicas: 1 forward: