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 <mrostecki@opensuse.org>
pull/215/head
Michal Rostecki 2022-01-20 11:56:21 +01:00
parent 3dd3fe9fb1
commit 4b7b81ae64
3 changed files with 42 additions and 25 deletions

View File

@ -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 -}}
{{/*

View File

@ -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

View File

@ -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 -}}