Skip to content

Commit

Permalink
Merge pull request #6 from BaizeAI/feature/global-imageRegistry
Browse files Browse the repository at this point in the history
+ add support for global.imageRegistry
  • Loading branch information
kebe7jun authored Sep 23, 2024
2 parents 868944f + cbf41a6 commit ad81360
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
21 changes: 21 additions & 0 deletions manifests/kcover/templates/_common.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
8 changes: 8 additions & 0 deletions manifests/kcover/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
2 changes: 1 addition & 1 deletion manifests/kcover/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifests/kcover/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions manifests/kcover/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ad81360

Please sign in to comment.