Skip to content

Commit e41680e

Browse files
author
Toby McLaughlin
committed
Use 'kibana' user for Kibana
1 parent 0c3a8c4 commit e41680e

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

docker-compose.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ services:
2525

2626
kibana:
2727
image: docker.elastic.co/kibana/kibana:${TAG}
28-
environment: ['ELASTICSEARCH_PASSWORD=${ELASTIC_PASSWORD}']
28+
environment:
29+
- ELASTICSEARCH_USERNAME=kibana
30+
- ELASTICSEARCH_PASSWORD=${ELASTIC_PASSWORD}
2931
ports: ['127.0.0.1:5601:5601']
3032
networks: ['stack']
3133
depends_on: ['elasticsearch']
@@ -102,6 +104,14 @@ services:
102104
networks: ['stack']
103105
depends_on: ['elasticsearch']
104106

107+
setup_kibana:
108+
image: centos:7
109+
volumes: ['./scripts/setup-kibana.sh:/usr/local/bin/setup-kibana.sh:ro']
110+
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-kibana.sh | tr -d "\r" | bash']
111+
environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
112+
networks: ['stack']
113+
depends_on: ['elasticsearch']
114+
105115
setup_auditbeat:
106116
image: docker.elastic.co/beats/auditbeat:${TAG}
107117
volumes: ['./scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro']

scripts/setup-kibana.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
es_url=http://elastic:${ELASTIC_PASSWORD}@elasticsearch:9200
6+
7+
# Wait for Elasticsearch to start up before doing anything.
8+
until curl -s $es_url -o /dev/null; do
9+
sleep 1
10+
done
11+
12+
# Set the password for the kibana user.
13+
# REF: https://www.elastic.co/guide/en/x-pack/6.0/setting-up-authentication.html#set-built-in-user-passwords
14+
until curl -s -H 'Content-Type:application/json' \
15+
-XPUT $es_url/_xpack/security/user/kibana/_password \
16+
-d "{\"password\": \"${ELASTIC_PASSWORD}\"}"
17+
do
18+
sleep 2
19+
echo Retrying...
20+
done

0 commit comments

Comments
 (0)