From 067af7c035b62191b40ec78c28a7a60f571dd7e7 Mon Sep 17 00:00:00 2001 From: weizhoublue Date: Wed, 25 Dec 2024 20:56:49 +0800 Subject: [PATCH] chart: repo over Signed-off-by: weizhoublue --- chart/templates/_helpers.tpl | 44 +++++++++++++++++++++++++++++++ chart/templates/clusteragent.yaml | 2 +- chart/templates/deployment.yaml | 4 +-- chart/values.yaml | 17 ++++++++++-- test/Makefile | 2 -- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index b7bc731a..9203b205 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -60,3 +60,47 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +return the controller image +*/}} +{{- define "bmc-operator.controller.image" -}} +{{- $registryName := .Values.image.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- if .Values.global.imageRegistryOverride }} + {{- printf "%s/%s" .Values.global.imageRegistryOverride $repositoryName -}} +{{- else -}} + {{- printf "%s/%s" $registryName $repositoryName -}} +{{- end -}} +{{- if .Values.image.digest }} + {{- print "@" .Values.image.digest -}} +{{- else if .Values.global.imageTagOverride -}} + {{- printf ":%s" .Values.global.imageTagOverride -}} +{{- else if .Values.image.tag -}} + {{- printf ":%s" .Values.image.tag -}} +{{- else -}} + {{- printf ":v%s" .Chart.AppVersion -}} +{{- end -}} +{{- end -}} + +{{/* +return the agent image +*/}} +{{- define "bmc-operator.agent.image" -}} +{{- $registryName := .Values.clusterAgent.agentYaml.image.registry -}} +{{- $repositoryName := .Values.clusterAgent.agentYaml.image.repository -}} +{{- if .Values.global.imageRegistryOverride }} + {{- printf "%s/%s" .Values.global.imageRegistryOverride $repositoryName -}} +{{- else -}} + {{- printf "%s/%s" $registryName $repositoryName -}} +{{- end -}} +{{- if .Values.clusterAgent.agentYaml.image.digest }} + {{- print "@" .Values.clusterAgent.agentYaml.image.digest -}} +{{- else if .Values.global.imageTagOverride -}} + {{- printf ":%s" .Values.global.imageTagOverride -}} +{{- else if .Values.clusterAgent.agentYaml.image.tag -}} + {{- printf ":%s" .Values.clusterAgent.agentYaml.image.tag -}} +{{- else -}} + {{- printf ":v%s" .Chart.AppVersion -}} +{{- end -}} +{{- end -}} diff --git a/chart/templates/clusteragent.yaml b/chart/templates/clusteragent.yaml index fbd5fbba..8577c0f3 100644 --- a/chart/templates/clusteragent.yaml +++ b/chart/templates/clusteragent.yaml @@ -9,7 +9,7 @@ metadata: spec: agentYaml: replicas: {{ .Values.clusterAgent.agentYaml.replicas }} - image: "{{ .Values.clusterAgent.agentYaml.image.repository }}:{{ default .Chart.Version .Values.clusterAgent.agentYaml.image.tag }}" + image: "{{ include "bmc-operator.agent.image" . }}" underlayInterface: "{{ .Values.clusterAgent.agentYaml.underlayInterface }}" {{- with .Values.clusterAgent.agentYaml.nodeAffinity }} nodeAffinity: diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index 4fc0ccb2..131fad70 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -30,7 +30,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ default .Chart.Version .Values.image.tag }}" + image: {{ include "bmc-operator.controller.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} args: - --metrics-bind-address=:{{ .Values.webhook.metricsPort }} @@ -39,7 +39,7 @@ spec: - --leader-elect env: - name: AGENT_IMAGE - value: "{{ .Values.clusterAgent.agentYaml.image.repository }}:{{ default .Chart.Version .Values.clusterAgent.agentYaml.image.tag }}" + value: {{ include "bmc-operator.agent.image" . }} - name: POD_NAMESPACE valueFrom: fieldRef: diff --git a/chart/values.yaml b/chart/values.yaml index 38cb11e5..6eb60a9b 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -5,10 +5,13 @@ replicaCount: 1 logLevel: "debug" image: - repository: ghcr.io/spidernet-io/bmc-controller + registry: "ghcr.io" + repository: "spidernet-io/bmc-controller" pullPolicy: IfNotPresent # tag will be overridden by version from Chart.yaml tag: "" + # Optional: image digest + digest: "" resources: limits: cpu: 500m @@ -22,10 +25,13 @@ securityContext: {} clusterAgent: agentYaml: image: - repository: ghcr.io/spidernet-io/bmc-agent + registry: "ghcr.io" + repository: "spidernet-io/bmc-agent" pullPolicy: IfNotPresent # tag will be overridden by version from Chart.yaml tag: "" + # Optional: image digest + digest: "" # Optional: network interface configuration underlayInterface: "" # Optional: Use host network for agent pods @@ -139,3 +145,10 @@ nodeSelector: {} tolerations: [] affinity: {} + +# Global configuration +global: + # Override image registry for all images + imageRegistryOverride: "" + # Override image tag for all images + imageTagOverride: "" diff --git a/test/Makefile b/test/Makefile index a4b2af4c..1d3c955c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -45,9 +45,7 @@ deploy: --namespace bmc \ --create-namespace \ --wait \ - --set image.repository=$(CONTROLLER_IMAGE) \ --set image.tag=$(VERSION) \ - --set clusterAgent.agentYaml.image.repository=$(AGENT_IMAGE) \ --set clusterAgent.agentYaml.image.tag=$(VERSION) \ --set clusterAgent.endpoint.https=false \ --set clusterAgent.agentYaml.hostNetwork=false \