Skip to content

Commit

Permalink
add user config (alipay#130)
Browse files Browse the repository at this point in the history
Co-authored-by: zt01902532 <[email protected]>
  • Loading branch information
zhangtong007 and zt01902532 authored Jul 15, 2024
1 parent af6e80c commit 4fb540a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deploy/helm/lunettes/templates/grafana/grafana-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3335,9 +3335,9 @@ data:
# disable creation of admin user on first start of grafana
;disable_initial_admin_creation = false
# default admin user, created on startup
;admin_user = admin
admin_user = {{ .Values.adminUser }}
# default admin password, can be changed before first start of grafana, or in profile settings
;admin_password = admin
admin_password = {{ .Values.adminPass }}
# default admin email, created on startup
;admin_email = admin@localhost
# used for signing
Expand Down
24 changes: 24 additions & 0 deletions deploy/helm/lunettes/templates/grafana/grafana-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ spec:
- name: grafana
image: {{ .Values.grafanaImage }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
lifecycle:
postStart:
exec:
command:
- bash
- -c
- |
wait_time=1
while true;
do
status=`curl -s -w %{http_code} -o /dev/null \
-X POST -H "Content-Type: application/json" \
-d '{"name":"{{ .Values.anonymousUser }}","email":"","login":"{{ .Values.anonymousUser }}","password":"{{ .Values.anonymousPass }}"}' \
http://{{ .Values.adminUser }}:{{ .Values.adminPass }}@localhost:3000/api/admin/users`
if [ -n "${status}" ] && [ "${status}X" == "200X" ];
then
echo "user {{ .Values.anonymousUser }} has created"
break
else
echo "user {{ .Values.anonymousUser }} created failed, status is ${status} retrying after ${wait_time}s..."
sleep ${wait_time}
wait_time=$((wait_time+wait_time))
fi
done
ports:
- containerPort: 3000
name: http-grafana
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/lunettes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ grafanaResources:
requests:
cpu: 250m
memory: 500Mi
adminUser: admin
adminPass: admin
anonymousUser: default
anonymousPass: default

# kibana
kibanaImage: kibana:7.17.13
Expand Down

0 comments on commit 4fb540a

Please sign in to comment.