Skip to content

Commit

Permalink
Merge pull request #11175 from stubenhuang/issue-imageRegistry-11171
Browse files Browse the repository at this point in the history
feat: 调整helm的镜像使其支持配置imageRegistry #11171
  • Loading branch information
mingshewhe authored Oct 31, 2024
2 parents 9337089 + 0643bea commit 3ac218d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
7 changes: 6 additions & 1 deletion helm-charts/core/ci/base/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ init:
iam: true
turbo: false
bkrepo: true
defaultImage: true
defaultImage:
enabled: true
image:
registry: registry-1.docker.io/bkci
repository: ci
tag: latest
plugin:
enabled: false
atoms:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-mysql
image: {{ .Values.kubernetesManager.image }}
image: {{ include "common.images.image" ( dict "imageRoot" .Values.backendImage "global" .Values.global) }}
imagePullPolicy: {{ .Values.backendImage.pullPolicy }}
command:
- "/bin/sh"
Expand All @@ -52,7 +52,7 @@ spec:
sleep 60s;
containers:
- name: kubernetes-manager
image: {{ .Values.kubernetesManager.image }}
image: {{ include "common.images.image" ( dict "imageRoot" .Values.backendImage "global" .Values.global) }}
imagePullPolicy: {{ .Values.backendImage.pullPolicy }}
{{- if .Values.kubernetesManager.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.kubernetesManager.containerSecurityContext "enabled" | toYaml | nindent 12 }}
Expand Down Expand Up @@ -109,7 +109,7 @@ spec:
{{- end}}
{{- if .Values.kubernetesManager.docker.enable }}
- name: kuberentes-manager-docker
image: {{ .Values.kubernetesManager.docker.image }}
image: "{{ .Values.kubernetesManager.docker.image.registry }}/{{ .Values.kubernetesManager.docker.image.repository }}:{{ .Values.kubernetesManager.docker.image.tag }}"
command: ["dockerd", "--host", "tcp://localhost:2375"]
{{- if .Values.kubernetesManager.docker.resources }}
resources: {{- toYaml .Values.kubernetesManager.docker.resources | nindent 12 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
{{- if .Values.mysql.enabled }}
initContainers:
- name: wait-for-mysql
image: {{ .Values.kubernetesManager.image }}
image: {{ include "common.images.image" ( dict "imageRoot" .Values.backendImage "global" .Values.global) }}
imagePullPolicy: {{ .Values.backendImage.pullPolicy }}
command:
- "/bin/sh"
Expand All @@ -34,7 +34,7 @@ spec:
{{- end }}
containers:
- name: init-sql
image: {{ .Values.kubernetesManager.image }}
image: {{ include "common.images.image" ( dict "imageRoot" .Values.backendImage "global" .Values.global) }}
imagePullPolicy: {{ .Values.backendImage.pullPolicy }}
workingDir: /data/workspace/support-files/sql
{{ $mysqlData := split ":" (include "bkci.mysqlAddr" .) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ data:
logPath: /data/devops/logs
builderConfigMapPath: /data/devops/config
buildAndPushImage:
image: {{ .Values.kubernetesManager.buildAndPushImage.image }}
image: {{ .Values.kubernetesManager.buildAndPushImage.image.registry }}/{{ .Values.kubernetesManager.buildAndPushImage.image.repository }}:{{ .Values.kubernetesManager.buildAndPushImage.image.tag }}
# 拉取kaniko需要的凭据,如果不填视为没有
pullImageRegistry:
server: {{ .Values.kubernetesManager.buildAndPushImage.server }}
Expand Down
25 changes: 21 additions & 4 deletions helm-charts/core/ci/local_chart/kubernetes-management/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ multiCluster:
# 镜像配置
backendImage:
pullPolicy: IfNotPresent
registry: registry-1.docker.io/bkci
repository: bkci-kubernetes-manager
tag: 0.0.32
pullPolicy: IfNotPresent
pullSecrets: []

# 内部数据源配置
mysql:
Expand Down Expand Up @@ -120,8 +125,6 @@ kubernetesManager:
maxReplicas: 3
targetCPU: 80
targetMemory: 80
# 使用的镜像
image: bkci/bkci-kubernetes-manager:0.0.32
# 决定每次helm部署时的构建机所在的命名空间,同时dockerInitSh也在那里,为空时默认为 {{ .Release.Namespace }}
builderNamespace:
redis:
Expand All @@ -136,12 +139,23 @@ kubernetesManager:
prometheusUrl:
# 构建并推送镜像相关
buildAndPushImage:
image: gcr.io/kaniko-project/executor:v1.9.0
# gcr.io/kaniko-project/executor:v1.9.0
image:
registry: gcr.io
repository: kaniko-project/executor
tag: v1.9.0
# 拉取kaniko需要的凭据,如果不填视为没有
pullImageRegistry:
server:
username:
password:
# 无编译构建机
buildlessDeployment:
# bkci/ci:latest
image:
registry: registry-1.docker.io/bkci
repository: ci
tag: latest
apiserver:
auth:
# 针对蓝盾流水线访问的超级权限token
Expand All @@ -156,7 +170,10 @@ kubernetesManager:
# manager使用docker相关配置,会启用特权模式容器
docker:
enable: false
image: docker:24.0.1-dind
image:
registry: registry-1.docker.io
repository: docker
tag: 24.0.1-dind
resources:
requests:
cpu: 50m
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/core/ci/templates/init/init.defaultImages.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 初始化构建镜像
{{ if .Values.init.defaultImage }}
{{ if .Values.init.defaultImage.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down Expand Up @@ -37,6 +37,6 @@ spec:
done
echo "{{ include "bkci.names.fullname" . }}-store is available";
curl "http://{{ include "bkci.names.fullname" . }}-store.{{ .Release.Namespace }}.svc.cluster.local/api/op/market/image/init" -X POST
curl "http://{{ include "bkci.names.fullname" . }}-store.{{ .Release.Namespace }}.svc.cluster.local/api/op/market/image/init" -X POST -d '{"imageRepoName":"{{ .Values.init.defaultImage.image.registry }}/{{ .Values.init.defaultImage.image.repository }}" , "imageTag":"{{ .Values.init.defaultImage.image.tag }}"}'
restartPolicy: OnFailure
{{- end -}}

0 comments on commit 3ac218d

Please sign in to comment.