From f7d7ed55ffbaf6e125a47bae698d222ba0386d1b Mon Sep 17 00:00:00 2001 From: "Roland.Ma" Date: Fri, 21 May 2021 09:10:13 +0000 Subject: [PATCH] inital admin account Signed-off-by: Roland.Ma --- config/ks-core/templates/_helpers.tpl | 12 ++++++++++++ config/ks-core/templates/account.yaml | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 config/ks-core/templates/account.yaml diff --git a/config/ks-core/templates/_helpers.tpl b/config/ks-core/templates/_helpers.tpl index 66b9a2d0a..695c969c4 100644 --- a/config/ks-core/templates/_helpers.tpl +++ b/config/ks-core/templates/_helpers.tpl @@ -61,3 +61,15 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Returns user's password or use default +*/}} +{{- define "getOrDefaultPass" }} +{{- $pws := (lookup "iam.kubesphere.io/v1alpha2" "User" "" .Name) -}} +{{- if $pws }} +{{- $pws.spec.password -}} +{{- else -}} +{{- .Default -}} +{{- end -}} +{{- end }} diff --git a/config/ks-core/templates/account.yaml b/config/ks-core/templates/account.yaml new file mode 100644 index 000000000..c6b2d4064 --- /dev/null +++ b/config/ks-core/templates/account.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: iam.kubesphere.io/v1alpha2 +kind: User +metadata: + name: admin + annotations: + iam.kubesphere.io/uninitialized: "true" + helm.sh/resource-policy: keep +spec: + email: admin@kubesphere.io + password: "{{ include "getOrDefaultPass" (dict "Name" "admin" "Default" "$2a$10$zcHepmzfKPoxCVCYZr5K7ORPZZ/ySe9p/7IUb/8u./xHrnSX2LOCO") }}" +status: + state: Active \ No newline at end of file