Fix issue [259] Support set different image registry server (#271)

* fix [259] Support set different image registry server

---------

Signed-off-by: jinxinwang <g1561925068@163.com>
This commit is contained in:
JustinWang 2023-11-14 16:37:30 +08:00 committed by GitHub
parent 86bbe4e891
commit f31cd40437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 5 deletions

View File

@ -8,7 +8,8 @@ helm install --kube-apiserver https://server:6443 --kube-token abcd --kube-insec
--set service.type=NodePort \
--set service.nodePort=30000 \
--set persistence.enabled=false \
--set image.repository=linuxsuren.docker.scarf.sh/linuxsuren/api-testing \
--set image.registry=linuxsuren.docker.scarf.sh \
--set image.repository=linuxsuren/api-testing \
--set image.tag=master
SERVER=http://server:30000 atest run -p git.yaml

View File

@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v0.0.2
version: v0.0.3
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to

View File

@ -60,3 +60,40 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{/* vim: set filetype=mustache: */}}
{{/*
Return the proper image name
{{ include "api-testing.images.image" (dict "imageRoot" .Values.path.to.the.image "global" .Values.global "Chart" .Chart) }}
*/}}
{{- define "api-testing.images.image" -}}
{{- $registryName := .imageRoot.registry -}}
{{- $repositoryName := .imageRoot.repository -}}
{{- $separator := ":" -}}
{{- $termination := .imageRoot.tag | toString -}}
{{- if not $termination }}
{{- $appVersion := .Chart.AppVersion | default "" -}}
{{- $termination = $appVersion | toString -}}
{{- end -}}
{{- if .global }}
{{- if .global.imageRegistry }}
{{- $registryName = .global.imageRegistry -}}
{{- end -}}
{{- end -}}
{{- if .imageRoot.digest }}
{{- $separator = "@" -}}
{{- $termination = .imageRoot.digest | toString -}}
{{- end -}}
{{- if $registryName }}
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
{{- else -}}
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper api-testing image name
*/}}
{{- define "api_testing.image" -}}
{{ include "api-testing.images.image" (dict "imageRoot" .Values.image "global" .Values.image "Chart" .Chart) }}
{{- end -}}

View File

@ -32,7 +32,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ include "api_testing.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- atest

View File

@ -5,10 +5,16 @@
replicaCount: 1
image:
registry: linuxsuren.docker.scarf.sh
repository: linuxsuren/api-testing
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
digest: ""
# Overrides the image tag whose default is the chart appVersion.
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""