add job-initialize-user

This commit is contained in:
Maarten de Waard 2022-04-04 16:56:08 +02:00
parent 3f0d6dc0fd
commit 8a89f94ec0
No known key found for this signature in database
GPG key ID: 1D3E893A657CC8DA
3 changed files with 82 additions and 4 deletions

View file

@ -0,0 +1,53 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "common.names.fullname" . }}-initialize-user
labels: {{- include "common.labels.standard" . | nindent 4 }}
component: dashboard
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
component: dashboard
spec:
restartPolicy: Never
containers:
- name: {{ .Chart.Name }}-login-create-admin
image: {{ template "backend.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
envFrom:
- configMapRef:
name: {{ include "common.names.fullname" . }}
{{- if .Values.backend.extraEnvVarsCM }}
- configMapRef:
name: {{ .Values.backend.extraEnvVarsCM }}
{{- end }}
{{- if .Values.backend.extraEnvVarsSecret }}
- secretRef:
name: {{ .Values.backend.extraEnvVarsSecret }}
{{- end }}
env:
- name: SETUP_EMAIL
value: {{ .Values.backend.initialUser.email }}
- name: SETUP_PASSWORD
value: {{ .Values.backend.initialUser.password }}
command: ["/bin/bash", "-c"]
args:
- flask db upgrade;
{{- if .Release.IsInstall }}
flask cli user create $SETUP_EMAIL;
flask cli user setpassword $SETUP_EMAIL $SETUP_PASSWORD;
flask cli app create dashboard Dashboard;
flask cli user setrole $SETUP_EMAIL dashboard admin;
{{- end }}

View file

@ -1,17 +1,38 @@
# Values you will likely want to override. See values.yaml for their meanings # Values you will likely want to override. See values.yaml for their meanings
dashboard: dashboard:
host: dashboard.oas.example.com host: dashboard.stackspin.example.com
backend: backend:
secretKey: My random secret key secretKey: My random secret key
# OIDC connection details
#
# oidc:
# clientSecret: ReplaceWithSecret
# baseUrl: https://sso.stackspin.example.org
# authorizationBaseUrl: https://sso.stackspin.example.org/oauth2/auth
# tokenUrl: https://sso.stackspin.example.org/oauth2/token
# Where to find the Kratos public url
kratos:
publicUrl: https://sso.stackspin.example.org/kratos
# Public URL of login panel
loginPanelUrl: https://dashboard.stackspin.example.org/web/
# Database connection
# databaseUrl: mysql+pymysql://stackspin:password@single-sign-on-database-mariadb/stackspin
initialUser:
email: admin@example.com
# password: Set a pasword for the initial user!
ingress: ingress:
enabled: true enabled: true
hostname: dashboard.oas.example.com hostname: dashboard.stackspin.example.com
# Get certificates with cert-manager # Get certificates with cert-manager
certManager: true certManager: true
tls: tls:
- hosts: - hosts:
- dashboard.oas.example.com - dashboard.stackspin.example.com
secretName: oas-dashboard secretName: stackspin-dashboard

View file

@ -271,6 +271,10 @@ backend:
loginPanelUrl: https://dashboard.stackspin.example.org/web/ loginPanelUrl: https://dashboard.stackspin.example.org/web/
databaseUrl: mysql+pymysql://stackspin:stackspin@single-sign-on-database-mariadb/stackspin databaseUrl: mysql+pymysql://stackspin:stackspin@single-sign-on-database-mariadb/stackspin
initialUser:
email: admin@example.com
# password: Set a pasword for the initial user!
## Kubernetes service configuration. For minikube, set this to NodePort, elsewhere use LoadBalancer or ClusterIP ## Kubernetes service configuration. For minikube, set this to NodePort, elsewhere use LoadBalancer or ClusterIP
## ##
service: service: