From 122d7e19c930c139256ca25786b6d16f53e83b49 Mon Sep 17 00:00:00 2001 From: YkeLit Date: Wed, 3 Apr 2024 13:14:59 +0800 Subject: [PATCH 1/4] feat: add jet-factory-chart --- charts/jet-factory-chart/.helmignore | 23 +++++ charts/jet-factory-chart/Chart.yaml | 24 +++++ charts/jet-factory-chart/README.md | 95 +++++++++++++++++++ .../jet-factory-chart/templates/_helpers.tpl | 74 +++++++++++++++ .../templates/configmap.yaml | 10 ++ .../templates/deployment.yaml | 50 ++++++++++ .../templates/secrets/docker-registry.yaml | 15 +++ .../templates/secrets/tls.yaml | 14 +++ .../jet-factory-chart/templates/service.yaml | 15 +++ .../traefik/compress-middleware.yaml | 7 ++ .../templates/traefik/ingress-route.yaml | 54 +++++++++++ .../templates/traefik/redirect-to-https.yaml | 8 ++ .../templates/traefik/server-headers.yaml | 8 ++ charts/jet-factory-chart/values.yaml | 63 ++++++++++++ 14 files changed, 460 insertions(+) create mode 100644 charts/jet-factory-chart/.helmignore create mode 100644 charts/jet-factory-chart/Chart.yaml create mode 100644 charts/jet-factory-chart/README.md create mode 100644 charts/jet-factory-chart/templates/_helpers.tpl create mode 100644 charts/jet-factory-chart/templates/configmap.yaml create mode 100644 charts/jet-factory-chart/templates/deployment.yaml create mode 100644 charts/jet-factory-chart/templates/secrets/docker-registry.yaml create mode 100644 charts/jet-factory-chart/templates/secrets/tls.yaml create mode 100644 charts/jet-factory-chart/templates/service.yaml create mode 100644 charts/jet-factory-chart/templates/traefik/compress-middleware.yaml create mode 100644 charts/jet-factory-chart/templates/traefik/ingress-route.yaml create mode 100644 charts/jet-factory-chart/templates/traefik/redirect-to-https.yaml create mode 100644 charts/jet-factory-chart/templates/traefik/server-headers.yaml create mode 100644 charts/jet-factory-chart/values.yaml diff --git a/charts/jet-factory-chart/.helmignore b/charts/jet-factory-chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/jet-factory-chart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/jet-factory-chart/Chart.yaml b/charts/jet-factory-chart/Chart.yaml new file mode 100644 index 0000000..ebf6edc --- /dev/null +++ b/charts/jet-factory-chart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: jet-factory-chart +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +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: 1.0.0 + +# 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 +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.0" diff --git a/charts/jet-factory-chart/README.md b/charts/jet-factory-chart/README.md new file mode 100644 index 0000000..3fd3121 --- /dev/null +++ b/charts/jet-factory-chart/README.md @@ -0,0 +1,95 @@ +# jet-factory-chart +## Installation +### Edit $release_name.values.yaml +1. Set imageCredentials for image pulling + +```yaml +# $release_name.values.yaml + +imageCredentials: + registry: registry.cn-hangzhou.aliyuncs.com + username: deploy-man@skylark + password: changeit +``` + +2. Set image info for image pulling + +```yaml +# $release_name.values.yaml + +image: + repository: jet/jet-factory + tag: "latest" + pullPolicy: IfNotPresent +``` + +3. Set host for app + +```yaml +# $release_name.values.yaml + +# Application +jetFactoryHost: factory.jet.localhost + +# 此处设置数据库相关配置 +database: + host: postgresql + port: "5432" + user: postgres + password: postgres + database: factory + # initcontainer 使用的 postgresql 镜像, 用于创建应用所需数据库 + image: postgres:latest +``` + +4. Set environments for app + +```yaml +# $release_name.values.yaml + +# jet-factory environment variable +env: + SECRET_KEY_BASE: "" + PHX_HOST: localhost +``` + +### Install + +```bash +# set release-name install +helm install -f $release_name.values.yaml release-name ./ +``` + +## HowTo + +### Setup TLS + +> 注:# 使用命令 `base64 -i tlsFile` 生成 `certificate` 与 `key` 的值 + +```yaml +# $release_name.values.yaml + +jetFactoryTLSSecret: + certificate: |- + base64 encoded certificate + key: |- + base64 encoded key +``` + +### Uninstall + +```bash +helm uninstall release-name +``` + +### Upgrade + +```bash +helm upgrade -f $release_name.values.yaml release-name ./ +``` + +### 指定 namespace 请使用一下参数 + +`--namespace jet-factory` : 指定名称空间 + +`--create-namespace` : 创建名称空间 diff --git a/charts/jet-factory-chart/templates/_helpers.tpl b/charts/jet-factory-chart/templates/_helpers.tpl new file mode 100644 index 0000000..a4844a3 --- /dev/null +++ b/charts/jet-factory-chart/templates/_helpers.tpl @@ -0,0 +1,74 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "jet-factory-chart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "jet-factory-chart.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "jet-factory-chart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "jet-factory-chart.labels" -}} +helm.sh/chart: {{ include "jet-factory-chart.chart" . }} +{{ include "jet-factory-chart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "jet-factory-chart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "jet-factory-chart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Return the proper image name +*/}} +{{- define "jet-factory-chart.image" }} +{{- $registryName := .Values.imageCredentials.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- $tag := .Values.image.tag | toString -}} +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end }} + +{{/* +Return the DATABASE_URL +*/}} +{{- define "jet-factory-chart.database-url" }} +{{- $databaseUser := .Values.database.user -}} +{{- $databasePassword := .Values.database.password -}} +{{- $databaseHost := .Values.database.host -}} +{{- $databasePort := .Values.database.port -}} +{{- $databaseDatabase := .Values.database.database -}} +{{- printf "ecto://%s:%s@%s:%s/%s" $databaseUser $databasePassword $databaseHost $databasePort $databaseDatabase -}} +{{- end }} + diff --git a/charts/jet-factory-chart/templates/configmap.yaml b/charts/jet-factory-chart/templates/configmap.yaml new file mode 100644 index 0000000..c27c147 --- /dev/null +++ b/charts/jet-factory-chart/templates/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + {{- include "jet-factory-chart.labels" . | nindent 4 }} + name: {{ .Chart.Name }}-env +data: + {{- .Values.env | toYaml | nindent 2}} + DATABASE_URL: {{ include "jet-factory-chart.database-url" . }} + diff --git a/charts/jet-factory-chart/templates/deployment.yaml b/charts/jet-factory-chart/templates/deployment.yaml new file mode 100644 index 0000000..ca9087e --- /dev/null +++ b/charts/jet-factory-chart/templates/deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "jet-factory-chart.fullname" . }} + labels: + {{- include "jet-factory-chart.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "jet-factory-chart.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "jet-factory-chart.selectorLabels" . | nindent 8 }} + spec: + imagePullSecrets: + - name: {{ include "jet-factory-chart.fullname" . }}-docker-registry-secret + initContainers: + - name: {{ .Chart.Name }}-create-database + command: ["sh", "-c"] + args: + - | + psql -c "SELECT 1" \ + "user={{ .Values.database.user }} password={{ .Values.database.password }} dbname={{ .Values.database.database }} host={{ .Values.database.host }}" || \ + psql -c "CREATE DATABASE {{ .Values.database.database }}" \ + "user={{ .Values.database.user }} password={{ .Values.database.password }} host={{ .Values.database.host }}" + image: {{ .Values.database.image }} + - name: {{ .Chart.Name }}-migrate-database + command: ["/bin/bash", "-c"] + args: ["/app/bin/db_migrate" ] + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-env + image: {{ include "jet-factory-chart.image" . }} + containers: + - name: {{ .Chart.Name }} + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-env + image: {{ include "jet-factory-chart.image" . }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: jet-factory + containerPort: 4000 + protocol: TCP + resources: + {{- .Values.resources | toYaml | nindent 12 }} diff --git a/charts/jet-factory-chart/templates/secrets/docker-registry.yaml b/charts/jet-factory-chart/templates/secrets/docker-registry.yaml new file mode 100644 index 0000000..4e1de64 --- /dev/null +++ b/charts/jet-factory-chart/templates/secrets/docker-registry.yaml @@ -0,0 +1,15 @@ +{{- define "imagePullSecret" }} +{{- with .Values.imageCredentials }} +{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }} +{{- end }} +{{- end }} + +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "jet-factory-chart.fullname" $ }}-docker-registry-secret + labels: + {{- include "jet-factory-chart.labels" $ | nindent 4 }} +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ template "imagePullSecret" . }} diff --git a/charts/jet-factory-chart/templates/secrets/tls.yaml b/charts/jet-factory-chart/templates/secrets/tls.yaml new file mode 100644 index 0000000..19ff7e3 --- /dev/null +++ b/charts/jet-factory-chart/templates/secrets/tls.yaml @@ -0,0 +1,14 @@ +{{- if .Values.jetTLSSecret | empty | not }} +{{- with .Values.jetTLSSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "jet-factory-chart.fullname" $ }}-tls-secret + labels: + {{ include "jet-factory-chart.labels" $ | nindent 4 }} +type: kubernetes.io/tls +data: + tls.crt: {{ required "Please provide `certificate` for appTLSSecret" .certificate | nindent 4 }} + tls.key: {{ required "Please provide `key` for appTLSSecret" .key | nindent 4 }} +{{- end }} +{{- end }} diff --git a/charts/jet-factory-chart/templates/service.yaml b/charts/jet-factory-chart/templates/service.yaml new file mode 100644 index 0000000..f3e31ab --- /dev/null +++ b/charts/jet-factory-chart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "jet-factory-chart.fullname" . }} + labels: + {{- include "jet-factory-chart.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + protocol: TCP + name: {{ include "jet-factory-chart.fullname" . }} + selector: + {{- include "jet-factory-chart.selectorLabels" . | nindent 4 }} diff --git a/charts/jet-factory-chart/templates/traefik/compress-middleware.yaml b/charts/jet-factory-chart/templates/traefik/compress-middleware.yaml new file mode 100644 index 0000000..e9c9c0c --- /dev/null +++ b/charts/jet-factory-chart/templates/traefik/compress-middleware.yaml @@ -0,0 +1,7 @@ +# Enable gzip compression +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: {{ include "jet-factory-chart.fullname" . }}-compress +spec: + compress: {} diff --git a/charts/jet-factory-chart/templates/traefik/ingress-route.yaml b/charts/jet-factory-chart/templates/traefik/ingress-route.yaml new file mode 100644 index 0000000..3168f1c --- /dev/null +++ b/charts/jet-factory-chart/templates/traefik/ingress-route.yaml @@ -0,0 +1,54 @@ +{{/* Middlewares for web ingress-routes */}} +{{- $webMiddlewares := list }} +{{- $webMiddlewares = append $webMiddlewares "compress" }} +{{- if .Values.jetTLSSecret | empty | not }} +{{- $webMiddlewares = append $webMiddlewares "redirect-to-https" }} +{{- end }} + +{{/* Middlewares for websecure ingress-routes */}} +{{- $websecureMiddlewares := list }} +{{- $websecureMiddlewares = append $websecureMiddlewares "compress" }} +{{- $websecureMiddlewares = append $websecureMiddlewares "server-headers" }} + +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: {{ include "jet-factory-chart.fullname" . }}-web +spec: + entryPoints: + - web + routes: + - match: HOST(`{{ .Values.jetHost }}`) + kind: Rule + services: + - name: {{ include "jet-factory-chart.fullname" $ }} + port: {{ include "jet-factory-chart.fullname" $ }} + passHostHeader: true + middlewares: + {{- range $webMiddlewares }} + - name: {{ include "jet-factory-chart.fullname" $ }}-{{ . }} + {{- end}} + +--- +{{- if .Values.jetTLSSecret | empty | not }} +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: {{ include "jet-factory-chart.fullname" . }}-websecure +spec: + entryPoints: + - websecure + routes: + - match: HOST(`{{ .Values.jetHost }}`) + kind: Rule + services: + - name: {{ include "jet-factory-chart.fullname" $ }} + passHostHeader: true + port: {{ include "jet-factory-chart.fullname" $ }} + middlewares: + {{- range $websecureMiddlewares }} + - name: {{ include "jet-factory-chart.fullname" $ }}-{{ . }} + {{- end}} + tls: + secretName: {{ include "jet-factory-chart.fullname" $ }}-tls-secret +{{- end }} diff --git a/charts/jet-factory-chart/templates/traefik/redirect-to-https.yaml b/charts/jet-factory-chart/templates/traefik/redirect-to-https.yaml new file mode 100644 index 0000000..b5ca21d --- /dev/null +++ b/charts/jet-factory-chart/templates/traefik/redirect-to-https.yaml @@ -0,0 +1,8 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: {{ include "jet-factory-chart.fullname" . }}-redirect-to-https +spec: + redirectScheme: + scheme: https + permanent: true diff --git a/charts/jet-factory-chart/templates/traefik/server-headers.yaml b/charts/jet-factory-chart/templates/traefik/server-headers.yaml new file mode 100644 index 0000000..610d328 --- /dev/null +++ b/charts/jet-factory-chart/templates/traefik/server-headers.yaml @@ -0,0 +1,8 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: {{ include "jet-factory-chart.fullname" . }}-server-headers +spec: + headers: + customRequestHeaders: + X-Forwarded-Proto: "https" diff --git a/charts/jet-factory-chart/values.yaml b/charts/jet-factory-chart/values.yaml new file mode 100644 index 0000000..c8facab --- /dev/null +++ b/charts/jet-factory-chart/values.yaml @@ -0,0 +1,63 @@ +# Default values for jet-factory-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +replicaCount: 1 + +image: + repository: jet/jet_factory + pullPolicy: IfNotPresent + tag: "latest" + +imageCredentials: + registry: registry.cn-hangzhou.aliyuncs.com + username: deploy-man@skylark + password: changeit + email: dev@byzan.team + +service: + type: ClusterIP + port: 4000 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +restartPolicy: Always + +# Application setting +jetFactoryHost: factory.jet.localhost +jetFactoryTLSSecret: + +database: + host: postgresql + port: "5432" + user: postgres + password: postgres + database: factory + # initcontainer 使用的 postgresql 镜像, 用于创建应用所需数据库 + image: postgres:latest + +# jet-factory environment variable +# DATABASE_URL 通过 configMap 设置 +env: + SECRET_KEY_BASE: "" + PHX_HOST: localhost From c90ac68995765463ed15b3af5987804bf1d57ed1 Mon Sep 17 00:00:00 2001 From: YkeLit Date: Wed, 3 Apr 2024 13:19:02 +0800 Subject: [PATCH 2/4] refactor: lint error --- charts/jet-factory-chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/jet-factory-chart/values.yaml b/charts/jet-factory-chart/values.yaml index c8facab..6a9bd41 100644 --- a/charts/jet-factory-chart/values.yaml +++ b/charts/jet-factory-chart/values.yaml @@ -58,6 +58,6 @@ database: # jet-factory environment variable # DATABASE_URL 通过 configMap 设置 -env: +env: SECRET_KEY_BASE: "" PHX_HOST: localhost From 475dd924034becee9202c4a4f50ba256da836575 Mon Sep 17 00:00:00 2001 From: YkeLit Date: Wed, 3 Apr 2024 13:24:27 +0800 Subject: [PATCH 3/4] refactor: lint error --- charts/jet-factory-chart/Chart.yaml | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/charts/jet-factory-chart/Chart.yaml b/charts/jet-factory-chart/Chart.yaml index ebf6edc..228957c 100644 --- a/charts/jet-factory-chart/Chart.yaml +++ b/charts/jet-factory-chart/Chart.yaml @@ -1,24 +1,22 @@ +# chart API 版本 apiVersion: v2 +# chart名称 name: jet-factory-chart +# chart 描述 description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. +# chart 类型 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/) +# chart 版本 version: 1.0.0 - -# 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 -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "1.0.0" +# 项目源码的URL列表 +sources: + - https://github.com/Byzanteam/jet-helm-chart +# 维护者信息 +maintainers: + # 维护者名字 + - name: YangKe + # 维护者邮箱 + email: yangke@jet.work +# 包含的应用版本 +appVersion: "0.1.0" From 1c903d30d8e43a5686af413f236c1dc7a453f21f Mon Sep 17 00:00:00 2001 From: YkeLit Date: Wed, 3 Apr 2024 13:36:23 +0800 Subject: [PATCH 4/4] feat: support existing image secret --- charts/jet-factory-chart/.helmignore | 3 +++ charts/jet-factory-chart/ci/test-values.yaml | 3 +++ charts/jet-factory-chart/templates/deployment.yaml | 5 +++++ .../jet-factory-chart/templates/secrets/docker-registry.yaml | 1 + charts/jet-factory-chart/values.yaml | 1 + 5 files changed, 13 insertions(+) create mode 100644 charts/jet-factory-chart/ci/test-values.yaml diff --git a/charts/jet-factory-chart/.helmignore b/charts/jet-factory-chart/.helmignore index 0e8a0eb..034c9a3 100644 --- a/charts/jet-factory-chart/.helmignore +++ b/charts/jet-factory-chart/.helmignore @@ -21,3 +21,6 @@ .idea/ *.tmproj .vscode/ +# Test dirs +tests/ +ci/ diff --git a/charts/jet-factory-chart/ci/test-values.yaml b/charts/jet-factory-chart/ci/test-values.yaml new file mode 100644 index 0000000..a98cffa --- /dev/null +++ b/charts/jet-factory-chart/ci/test-values.yaml @@ -0,0 +1,3 @@ +fullnameOverride: jet-factory +image: + existingImageSecret: docker-registry-secret diff --git a/charts/jet-factory-chart/templates/deployment.yaml b/charts/jet-factory-chart/templates/deployment.yaml index ca9087e..ef2c841 100644 --- a/charts/jet-factory-chart/templates/deployment.yaml +++ b/charts/jet-factory-chart/templates/deployment.yaml @@ -16,8 +16,13 @@ spec: labels: {{- include "jet-factory-chart.selectorLabels" . | nindent 8 }} spec: + # TODO: <24-04-03, yangek> remove .Values.imageCredentials# imagePullSecrets: + {{- if .Values.image.existingImageSecret }} + - name: {{ .Values.image.existingImageSecret }} + {{- else }} - name: {{ include "jet-factory-chart.fullname" . }}-docker-registry-secret + {{- end }} initContainers: - name: {{ .Chart.Name }}-create-database command: ["sh", "-c"] diff --git a/charts/jet-factory-chart/templates/secrets/docker-registry.yaml b/charts/jet-factory-chart/templates/secrets/docker-registry.yaml index 4e1de64..1ab0795 100644 --- a/charts/jet-factory-chart/templates/secrets/docker-registry.yaml +++ b/charts/jet-factory-chart/templates/secrets/docker-registry.yaml @@ -1,3 +1,4 @@ +# TODO: <24-04-03, yangek> remove .Values.imageCredentials# {{- define "imagePullSecret" }} {{- with .Values.imageCredentials }} {{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }} diff --git a/charts/jet-factory-chart/values.yaml b/charts/jet-factory-chart/values.yaml index 6a9bd41..08f5a33 100644 --- a/charts/jet-factory-chart/values.yaml +++ b/charts/jet-factory-chart/values.yaml @@ -11,6 +11,7 @@ image: repository: jet/jet_factory pullPolicy: IfNotPresent tag: "latest" + existingImageSecret: "" imageCredentials: registry: registry.cn-hangzhou.aliyuncs.com