From cbf41a6e96e79022867140245405fcc9e95ef3ea Mon Sep 17 00:00:00 2001 From: Kebe Date: Mon, 23 Sep 2024 03:53:30 +0000 Subject: [PATCH] + add support for global.imageRegistry --- manifests/kcover/templates/_common.tpl | 21 +++++++++++++++++++++ manifests/kcover/templates/_helpers.tpl | 8 ++++++++ manifests/kcover/templates/daemonset.yaml | 2 +- manifests/kcover/templates/deployment.yaml | 2 +- manifests/kcover/values.yaml | 7 +++++-- 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 manifests/kcover/templates/_common.tpl diff --git a/manifests/kcover/templates/_common.tpl b/manifests/kcover/templates/_common.tpl new file mode 100644 index 0000000..c289eb7 --- /dev/null +++ b/manifests/kcover/templates/_common.tpl @@ -0,0 +1,21 @@ +{{- define "common.images.image" -}} +{{- $registryName := .imageRoot.registry -}} +{{- $repositoryName := .imageRoot.repository -}} +{{- $tag := .defaultTag -}} +{{- if .global }} + {{- if .global.imageRegistry }} + {{- $registryName = .global.imageRegistry -}} + {{- end -}} +{{- end -}} +{{- if .imageRoot.registry }} + {{- $registryName = .imageRoot.registry -}} +{{- end -}} +{{- if .imageRoot.tag }} + {{- $tag = .imageRoot.tag -}} +{{- end -}} +{{- if $registryName }} +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- else -}} +{{- printf "%s:%s" $repositoryName $tag -}} +{{- end -}} +{{- end -}} diff --git a/manifests/kcover/templates/_helpers.tpl b/manifests/kcover/templates/_helpers.tpl index dd0f7a9..e73e407 100644 --- a/manifests/kcover/templates/_helpers.tpl +++ b/manifests/kcover/templates/_helpers.tpl @@ -60,3 +60,11 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{- define "controller.image" -}} +{{ include "common.images.image" (dict "imageRoot" .Values.controller.image "global" .Values.global "defaultTag" .Chart.Version) }} +{{- end -}} + +{{- define "agent.image" -}} +{{ include "common.images.image" (dict "imageRoot" .Values.agent.image "global" .Values.global "defaultTag" .Chart.Version) }} +{{- end -}} diff --git a/manifests/kcover/templates/daemonset.yaml b/manifests/kcover/templates/daemonset.yaml index 76236c3..ea898f9 100644 --- a/manifests/kcover/templates/daemonset.yaml +++ b/manifests/kcover/templates/daemonset.yaml @@ -29,7 +29,7 @@ spec: - name: agent securityContext: {{- toYaml .Values.agent.securityContext | nindent 12 }} - image: "{{ .Values.agent.image.registry }}/{{ .Values.agent.image.repository }}:{{ .Values.agent.image.tag | default .Chart.AppVersion }}" + image: {{ template "agent.image" . }} imagePullPolicy: {{ .Values.agent.image.pullPolicy }} env: - name: FAST_RECOVERY_NODE_NAME diff --git a/manifests/kcover/templates/deployment.yaml b/manifests/kcover/templates/deployment.yaml index d663038..f482726 100644 --- a/manifests/kcover/templates/deployment.yaml +++ b/manifests/kcover/templates/deployment.yaml @@ -33,7 +33,7 @@ spec: {{- toYaml .Values.controller.podSecurityContext | nindent 8 }} containers: - name: controller-container - image: "{{ .Values.controller.image.registry }}/{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}" + image: {{ template "controller.image" . }} imagePullPolicy: {{ .Values.controller.image.pullPolicy }} env: - name: FAST_RECOVERY_NODE_NAME diff --git a/manifests/kcover/values.yaml b/manifests/kcover/values.yaml index f155504..1406b09 100644 --- a/manifests/kcover/values.yaml +++ b/manifests/kcover/values.yaml @@ -16,9 +16,12 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: "" +global: + imageRegistry: ghcr.io + agent: image: - registry: ghcr.io + registry: '' repository: baizeai/kcover-agent pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. @@ -76,7 +79,7 @@ agent: controller: image: - registry: ghcr.io + registry: '' repository: baizeai/kcover-controller pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion.