From 9704b7b5c9927e7e221304b2f7f3cb2037d7ab97 Mon Sep 17 00:00:00 2001 From: Sharon Gur Date: Sun, 15 Mar 2020 14:47:00 +0200 Subject: [PATCH] refactor files to support stack deployment of elasticsearch logtash and kibana --- .env | 4 ++-- config/elasticsearch/elasticsearch.yml | 1 + config/kibana/kibana.yml | 7 ++++--- config/logstash/logstash.yml | 4 ++-- docker-compose.yml | 2 ++ scripts/setup-elasticsearch.sh | 6 +++++- scripts/setup.sh | 2 +- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.env b/.env index c342d84..e9849a3 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -TAG=6.6.0 -ELASTIC_VERSION=6.6.0 +TAG=7.6.1 +ELASTIC_VERSION=7.6.1 diff --git a/config/elasticsearch/elasticsearch.yml b/config/elasticsearch/elasticsearch.yml index 0f77d84..23ec225 100644 --- a/config/elasticsearch/elasticsearch.yml +++ b/config/elasticsearch/elasticsearch.yml @@ -1,6 +1,7 @@ cluster.name: "docker-cluster" network.host: 0.0.0.0 transport.host: 0.0.0.0 +node.name: elasticsearch # minimum_master_nodes need to be explicitly set when bound on a public IP # set to 1 to allow single node clusters diff --git a/config/kibana/kibana.yml b/config/kibana/kibana.yml index 37857aa..808dde1 100644 --- a/config/kibana/kibana.yml +++ b/config/kibana/kibana.yml @@ -2,11 +2,12 @@ server.name: kibana server.host: "0" -elasticsearch.url: https://elasticsearch:9200 +elasticsearch.hosts: ["https://elasticsearch:9200"] + # elasticsearch.password is stored in `kibana.keystore` elasticsearch.username: kibana elasticsearch.ssl.certificateAuthorities: ["/usr/share/kibana/config/certs/ca/ca.crt"] server.ssl.enabled: false -#server.ssl.certificate: /usr/share/kibana/config/certs/kibana/kibana.crt -#server.ssl.key: /usr/share/kibana/config/certs/kibana/kibana.key +server.ssl.certificate: /usr/share/kibana/config/certs/kibana/kibana.crt +server.ssl.key: /usr/share/kibana/config/certs/kibana/kibana.key xpack.monitoring.ui.container.elasticsearch.enabled: true diff --git a/config/logstash/logstash.yml b/config/logstash/logstash.yml index b53754f..ec60634 100644 --- a/config/logstash/logstash.yml +++ b/config/logstash/logstash.yml @@ -1,7 +1,7 @@ http.host: 0.0.0.0 # read password from logstash.keystore xpack.monitoring.elasticsearch.password: ${ELASTIC_PASSWORD} -xpack.monitoring.elasticsearch.url: https://elasticsearch:9200 +xpack.monitoring.elasticsearch.hosts: ["https://elasticsearch:9200"] xpack.monitoring.elasticsearch.username: logstash_system -xpack.monitoring.elasticsearch.ssl.ca: /usr/share/logstash/config/certs/ca/ca.crt +xpack.monitoring.elasticsearch.ssl.certificate_authority: /usr/share/logstash/config/certs/ca/ca.crt diff --git a/docker-compose.yml b/docker-compose.yml index 346dd61..c5e9020 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,8 @@ services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:${TAG} container_name: elasticsearch + environment: + - cluster.initial_master_nodes=elasticsearch secrets: - source: ca.crt target: /usr/share/elasticsearch/config/certs/ca/ca.crt diff --git a/scripts/setup-elasticsearch.sh b/scripts/setup-elasticsearch.sh index 13830e8..d2c22a3 100755 --- a/scripts/setup-elasticsearch.sh +++ b/scripts/setup-elasticsearch.sh @@ -7,7 +7,7 @@ fi # Determine if x-pack is enabled echo "Determining if x-pack is installed..." -if [[ -d /usr/share/elasticsearch/bin/x-pack ]]; then +if [[ -f /usr/share/elasticsearch/bin/x-pack-env ]]; then if [[ -n "$ELASTIC_PASSWORD" ]]; then echo "=== CREATE Keystore ===" @@ -37,6 +37,10 @@ if [[ -d /usr/share/elasticsearch/bin/x-pack ]]; then echo "CA directory exists, removing..." rm -rf /config/ssl/ca fi + echo "Install unzip if needed..." + if ! command -v unzip &>/dev/null; then + yum -qy install unzip + fi echo "Unzip ca files..." unzip /config/ssl/docker-cluster-ca.zip -d /config/ssl diff --git a/scripts/setup.sh b/scripts/setup.sh index daccbf3..7028a9d 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -16,7 +16,7 @@ docker-compose -f docker-compose.yml -f docker-compose.setup.yml up setup_elasti # setup kibana and logstash (and system passwords) docker-compose -f docker-compose.yml -f docker-compose.setup.yml up setup_kibana setup_logstash # setup beats and apm server -docker-compose -f docker-compose.yml -f docker-compose.setup.yml up setup_auditbeat setup_filebeat setup_heartbeat setup_metricbeat setup_packetbeat setup_apm_server +#docker-compose -f docker-compose.yml -f docker-compose.setup.yml up setup_auditbeat setup_filebeat setup_heartbeat setup_metricbeat setup_packetbeat setup_apm_server printf "Setup completed successfully. To start the stack please run:\n\t docker-compose up -d\n" printf "\nIf you wish to remove the setup containers please run:\n\tdocker-compose -f docker-compose.yml -f docker-compose.setup.yml down --remove-orphans\n"