38 lines
1.6 KiB
Plaintext
38 lines
1.6 KiB
Plaintext
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: create-kibana-user
|
|
namespace: {{ .Release.Namespace }}
|
|
annotations:
|
|
"helm.sh/hook": post-install,post-upgrade
|
|
"helm.sh/hook-delete-policy": before-hook-creation
|
|
spec:
|
|
template:
|
|
spec:
|
|
restartPolicy: OnFailure
|
|
containers:
|
|
- name: create-kibana-user
|
|
image: curlimages/curl:8.6.0
|
|
command: ["/bin/sh", "-c"]
|
|
args:
|
|
- |
|
|
echo "waiting for elasticsearch..."
|
|
until curl -s -u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD} http://service-elasticsearch:9200/_cluster/health | grep -q '"status":"green"'; do
|
|
echo "elasticsearch not ready yet..."
|
|
sleep 5
|
|
done
|
|
|
|
echo "checking if user '${KIBANA_USERNAME}' exists..."
|
|
USER_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" -u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD} http://service-elasticsearch:9200/_security/user/${KIBANA_USERNAME})
|
|
|
|
if [ "$USER_EXISTS" -eq 200 ]; then
|
|
echo "user '${KIBANA_USERNAME}' already exists."
|
|
else
|
|
echo "creating user '${KIBANA_USERNAME}'..."
|
|
curl -s -X POST -u "elastic:{{ required ".Values.elastic.password entry is required!" .Values.elastic.password }}" -H "Content-Type: application/json" https://localhost:9200/_security/user/kibana_system/_password -d "{\"password\" : \"{{ required ".Values.kibana.password entry is required!" .Values.kibana.password }}\"}"
|
|
echo "user '${KIBANA_USERNAME}' created."
|
|
fi
|
|
envFrom:
|
|
- secretRef:
|
|
name: secret-elasticsearch
|