From 4b7b81ae64a337cd7b35697f1d5b2e7e837fc78b Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Thu, 20 Jan 2022 11:56:21 +0100 Subject: [PATCH] cilium: Fix the usage of `system_default_registry` template Before this change, we tried to include `system_default_registry` template inside `cilium.image`. But it seems like nested templates can't access Values. This change fixes that by using `system_default_registry` directly in yaml manifests. Signed-off-by: Michal Rostecki --- .../patch/templates/_helpers.tpl.patch | 11 ----- .../cilium-agent/daemonset.yaml.patch | 44 ++++++++++++++++++- .../cilium-operator/_helpers.tpl.patch | 12 ----- 3 files changed, 42 insertions(+), 25 deletions(-) delete mode 100644 packages/cilium/generated-changes/patch/templates/cilium-operator/_helpers.tpl.patch diff --git a/packages/cilium/generated-changes/patch/templates/_helpers.tpl.patch b/packages/cilium/generated-changes/patch/templates/_helpers.tpl.patch index 833cec0..d551335 100644 --- a/packages/cilium/generated-changes/patch/templates/_helpers.tpl.patch +++ b/packages/cilium/generated-changes/patch/templates/_helpers.tpl.patch @@ -15,14 +15,3 @@ {{/* Render full image name from given values, e.g: ``` -@@ -18,8 +26,9 @@ - will return `quay.io/cilium/cilium:v1.10.1@abcdefgh` - */}} - {{- define "cilium.image" -}} -+{{- $registry := include "system_default_registry" . -}} - {{- $digest := (.useDigest | default false) | ternary (printf "@%s" .digest) "" -}} --{{- printf "%s:%s%s" .repository .tag $digest -}} -+{{- printf "%s%s:%s%s" $registry .repository .tag $digest -}} - {{- end -}} - - {{/* diff --git a/packages/cilium/generated-changes/patch/templates/cilium-agent/daemonset.yaml.patch b/packages/cilium/generated-changes/patch/templates/cilium-agent/daemonset.yaml.patch index 4da3ab3..76aa4c9 100644 --- a/packages/cilium/generated-changes/patch/templates/cilium-agent/daemonset.yaml.patch +++ b/packages/cilium/generated-changes/patch/templates/cilium-agent/daemonset.yaml.patch @@ -1,6 +1,42 @@ --- charts-original/templates/cilium-agent/daemonset.yaml +++ charts/templates/cilium-agent/daemonset.yaml -@@ -390,6 +390,8 @@ +@@ -70,7 +70,7 @@ + {{- end }} + containers: + - name: cilium-agent +- image: {{ include "cilium.image" .Values.image | quote }} ++ image: "{{ template "system_default_registry" . }}{{ include "cilium.image" .Values.image }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.sleepAfterInit }} + command: +@@ -321,7 +321,7 @@ + {{- end }} + {{- if .Values.monitor.enabled }} + - name: cilium-monitor +- image: {{ include "cilium.image" .Values.image | quote }} ++ image: "{{ template "system_default_registry" . }}{{ include "cilium.image" .Values.image }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["cilium"] + args: +@@ -348,7 +348,7 @@ + # Required to mount cgroup2 filesystem on the underlying Kubernetes node. + # We use nsenter command with host's cgroup and mount namespaces enabled. + - name: mount-cgroup +- image: {{ include "cilium.image" .Values.image | quote }} ++ image: "{{ template "system_default_registry" . }}{{ include "cilium.image" .Values.image }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: CGROUP_ROOT +@@ -377,7 +377,7 @@ + {{- end }} + {{- if and .Values.nodeinit.enabled .Values.nodeinit.bootstrapFile }} + - name: wait-for-node-init +- image: {{ include "cilium.image" .Values.image | quote }} ++ image: "{{ template "system_default_registry" . }}{{ include "cilium.image" .Values.image }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - sh +@@ -390,9 +390,11 @@ volumeMounts: - name: cilium-bootstrap-file mountPath: {{ .Values.nodeinit.bootstrapFile }} @@ -8,4 +44,8 @@ + privileged: true {{- end }} - name: clean-cilium-state - image: {{ include "cilium.image" .Values.image | quote }} +- image: {{ include "cilium.image" .Values.image | quote }} ++ image: "{{ template "system_default_registry" . }}{{ include "cilium.image" .Values.image }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - /init-container.sh diff --git a/packages/cilium/generated-changes/patch/templates/cilium-operator/_helpers.tpl.patch b/packages/cilium/generated-changes/patch/templates/cilium-operator/_helpers.tpl.patch deleted file mode 100644 index e144996..0000000 --- a/packages/cilium/generated-changes/patch/templates/cilium-operator/_helpers.tpl.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- charts-original/templates/cilium-operator/_helpers.tpl -+++ charts/templates/cilium-operator/_helpers.tpl -@@ -26,7 +26,8 @@ - Return cilium operator image - */}} - {{- define "cilium.operator.image" -}} -+{{- $registry := include "system_default_registry" . }} - {{- $cloud := include "cilium.operator.cloud" . }} - {{- $imageDigest := include "cilium.operator.imageDigestName" . }} --{{- printf "%s-%s%s:%s%s" .Values.operator.image.repository $cloud .Values.operator.image.suffix .Values.operator.image.tag $imageDigest -}} -+{{- printf "%s%s-%s%s:%s%s" $registry .Values.operator.image.repository $cloud .Values.operator.image.suffix .Values.operator.image.tag $imageDigest -}} - {{- end -}}