From 63a0a46152af6b5e63804850139cd7c1ab991ff5 Mon Sep 17 00:00:00 2001 From: wojiushixiaobai <296015668@qq.com> Date: Tue, 17 Aug 2021 13:42:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=20hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/pre-install-initdb.yaml | 63 +++++++++++++++++++++++++++++++ values.yaml | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 templates/pre-install-initdb.yaml diff --git a/templates/pre-install-initdb.yaml b/templates/pre-install-initdb.yaml new file mode 100644 index 0000000..65ba83a --- /dev/null +++ b/templates/pre-install-initdb.yaml @@ -0,0 +1,63 @@ +{{- if .Values.core.enabled }} +{{- with .Values.core }} +{{- $fullName := printf "%s-%s" (include "jumpserver.fullname" $) "jms-init-db" }} +{{- $containerName := "jms-init-db" }} +{{- $image := printf "%s:%s" .image.repository .image.tag }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ $fullName }} + labels: + app.jumpserver.org/name: {{ $containerName }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "-5" + "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation +spec: + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "jumpserver.name" $ }} + app.kubernetes.io/instance: {{ $.Release.Name }} + {{- toYaml .labels | nindent 8 }} + spec: + serviceAccountName: {{ template "jumpserver.serviceAccountName" $ }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - name: {{ $containerName }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + image: "{{$image}}" + imagePullPolicy: {{ .image.pullPolicy }} + command: + - /bin/bash + - "-c" + - cd /opt/jumpserver && ./jms upgrade_db + env: + - name: "SECRET_KEY" + value: "{{.config.secretKey}}" + - name: "BOOTSTRAP_TOKEN" + value: "{{.config.bootstrapToken}}" + - name: "DB_HOST" + value: "{{.config.db.host}}" + - name: "DB_PORT" + value: "{{.config.db.port}}" + - name: "DB_USER" + value: "{{.config.db.user}}" + - name: "DB_PASSWORD" + value: "{{.config.db.password}}" + - name: "DB_NAME" + value: "{{.config.db.name}}" + - name: "REDIS_HOST" + value: "{{.config.redis.host}}" + - name: "REDIS_PORT" + value: "{{.config.redis.port}}" + - name: "REDIS_PASSWORD" + value: "{{.config.redis.password}}" + {{- with .env }} + {{- tpl (toYaml .) $ | nindent 12 }} + {{- end }} + restartPolicy: Never +{{- end }} +{{- end }} diff --git a/values.yaml b/values.yaml index 0e2740e..a5c3371 100644 --- a/values.yaml +++ b/values.yaml @@ -316,7 +316,7 @@ nginx: replicaCount: 1 image: - repository: docker.io/jumpserver/web + repository: docker.io/jumpserver/nginx tag: v2.12.2 pullPolicy: IfNotPresent