override images in helm chart (#771)

Signed-off-by: Zhiwei Yin <zyin@redhat.com>
This commit is contained in:
Zhiwei Yin
2024-12-17 17:23:31 +08:00
committed by GitHub
parent 17e05da4b8
commit 1d48226873
8 changed files with 99 additions and 19 deletions

View File

@@ -13,11 +13,52 @@
{{/* Define the image tag. */}}
{{- define "imageTag" }}
{{- if .Values.images.tag }}
{{- printf "%s" .Values.images.tag }}
{{- define "registrationImage" }}
{{- if .Values.images.overrides.registrationImage }}
{{- printf "%s" .Values.images.overrides.registrationImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/registration:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s" .Chart.AppVersion }}
{{- printf "%s/registration:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- define "workImage" }}
{{- if .Values.images.overrides.workImage }}
{{- printf "%s" .Values.images.overrides.workImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/work:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s/work:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- define "addOnManagerImage" }}
{{- if .Values.images.overrides.addOnManagerImage }}
{{- printf "%s" .Values.images.overrides.addOnManagerImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/addon-manager:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s/addon-manager:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- define "placementImage" }}
{{- if .Values.images.overrides.placementImage }}
{{- printf "%s" .Values.images.overrides.placementImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/placement:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s/placement:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- define "operatorImage" }}
{{- if .Values.images.overrides.operatorImage }}
{{- printf "%s" .Values.images.overrides.operatorImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/registration-operator:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s/registration-operator:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}

View File

@@ -4,10 +4,10 @@ kind: ClusterManager
metadata:
name: cluster-manager
spec:
registrationImagePullSpec: {{ .Values.images.registry }}/registration:{{ template "imageTag" . }}
workImagePullSpec: {{ .Values.images.registry }}/work:{{ template "imageTag" . }}
placementImagePullSpec: {{ .Values.images.registry }}/placement:{{ template "imageTag" . }}
addOnManagerImagePullSpec: {{ .Values.images.registry }}/addon-manager:{{ template "imageTag" . }}
registrationImagePullSpec: "{{ template "registrationImage" . }}"
workImagePullSpec: "{{ template "workImage" . }}"
placementImagePullSpec: "{{ template "placementImage" . }}"
addOnManagerImagePullSpec: "{{ template "addOnManagerImage" . }}"
deployOption:
mode: {{ .Values.clusterManager.mode }}
{{- with .Values.clusterManager.resourceRequirement }}

View File

@@ -32,7 +32,7 @@ spec:
serviceAccountName: cluster-manager
containers:
- name: registration-operator
image: "{{ .Values.images.registry }}/registration-operator:{{ template "imageTag" . }}"
image: "{{ template "operatorImage" . }}"
imagePullPolicy: {{ .Values.images.imagePullPolicy }}
args:
- "/registration-operator"

View File

@@ -4,6 +4,14 @@ replicaCount: 3
# image configurations for all images used in operator deployment and clusterManager CR.
images:
# the overrides can replace the corresponding image if not empty.
overrides:
registrationImage: ""
workImage: ""
placementImage: ""
addOnManagerImage: ""
operatorImage: ""
# registry and tag work on all images, but the image will be replaced by overrides if the image in overrides is not empty.
# The registry name must NOT contain a trailing slash.
registry: quay.io/open-cluster-management
# The image tag is the appVersion by default, can be replaced by this version.
@@ -11,6 +19,8 @@ images:
imagePullPolicy: IfNotPresent
# The image pull secret name is open-cluster-management-image-pull-credentials.
# Please set the userName/password or the dockerConfigJson if you use a private image registry.
# The registry will be set in the generated credential if you set userName/password.
# Suggest to use dockerConfigJson if you set overrides here.
# The image pull secret is fixed into the serviceAccount, you can also set
# `createImageCredentials` to `false` and create the pull secret manually.
imageCredentials:

View File

@@ -14,11 +14,32 @@ Create secret to access docker registry
{{- end }}
{{- end }}
{{/* Define the image tag. */}}
{{- define "imageTag" }}
{{- if .Values.images.tag }}
{{- printf "%s" .Values.images.tag }}
{{- define "registrationImage" }}
{{- if .Values.images.overrides.registrationImage }}
{{- printf "%s" .Values.images.overrides.registrationImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/registration:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s" .Chart.AppVersion }}
{{- printf "%s/registration:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- define "workImage" }}
{{- if .Values.images.overrides.workImage }}
{{- printf "%s" .Values.images.overrides.workImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/work:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s/work:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- define "operatorImage" }}
{{- if .Values.images.overrides.operatorImage }}
{{- printf "%s" .Values.images.overrides.operatorImage }}
{{- else if .Values.images.tag }}
{{- printf "%s/registration-operator:%s" .Values.images.registry .Values.images.tag }}
{{- else }}
{{- printf "%s/registration-operator:%s" .Values.images.registry .Chart.AppVersion }}
{{- end }}
{{- end }}

View File

@@ -10,9 +10,9 @@ metadata:
spec:
deployOption:
mode: {{ .Values.klusterlet.mode | default "Singleton" }}
registrationImagePullSpec: "{{ .Values.images.registry }}/registration:{{ template "imageTag" . }}"
workImagePullSpec: "{{ .Values.images.registry }}/work:{{ template "imageTag" . }}"
imagePullSpec: "{{ .Values.images.registry }}/registration-operator:{{ template "imageTag" . }}"
registrationImagePullSpec: "{{ template "registrationImage" . }}"
workImagePullSpec: "{{ template "workImage" . }}"
imagePullSpec: "{{ template "operatorImage" . }}"
clusterName: {{ .Values.klusterlet.clusterName }}
{{- if or ( eq .Values.klusterlet.mode "Hosted") (eq .Values.klusterlet.mode "SingletonHosted") }}
namespace: "open-cluster-management-{{ .Values.klusterlet.clusterName }}"

View File

@@ -35,7 +35,7 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: klusterlet
image: "{{ .Values.images.registry }}/registration-operator:{{ template "imageTag" . }}"
image: "{{ template "operatorImage" . }}"
imagePullPolicy: {{ .Values.images.imagePullPolicy }}
args:
- "/registration-operator"

View File

@@ -3,6 +3,12 @@ replicaCount: 3
# image configurations for all images used in operator deployment and klusterlet CR.
images:
# the overrides can replace the corresponding image if not empty.
overrides:
registrationImage: ""
workImage: ""
operatorImage: ""
# registry and tag work on all images, but the image will be replaced by overrides if the image in overrides is not empty.
# The registry name must NOT contain a trailing slash.
registry: quay.io/open-cluster-management
# The image tag is the appVersion by default, can be replaced by this version.
@@ -10,6 +16,8 @@ images:
imagePullPolicy: IfNotPresent
# The image pull secret name is open-cluster-management-image-pull-credentials.
# Please set the userName/password or the dockerConfigJson if you use a private image registry.
# The registry will be set in the generated credential if you set userName/password.
# Suggest to use dockerConfigJson if you set overrides here.
# The image pull secret is fixed into the serviceAccount, you can also set
# `createImageCredentials` to `false` and create the pull secret manually.
imageCredentials: