Skip to content

Commit

Permalink
Fix ports in .env not affecting Elasticsearch and Kibana Ports (fixes #…
Browse files Browse the repository at this point in the history
…83)

Signed-off-by: Sherif Abdel-Naby <[email protected]>
  • Loading branch information
sherifabdlnaby committed Sep 28, 2023
1 parent 44f5cbe commit f95e4ff
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ elk: ## Start ELK.

up:
@make elk
@echo "Visit Kibana: https://localhost:5601"
@echo "Visit Kibana: https://localhost:5601 (user: elastic, password: changeme) [Unless you changed values in .env]"

monitoring: ## Start ELK Monitoring.
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_MONITORING} up -d --build ${ELK_MONITORING}
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
ELASTIC_NODE_NAME: ${ELASTIC_NODE_NAME_1}
ELASTIC_INIT_MASTER_NODE: ${ELASTIC_INIT_MASTER_NODE}
ELASTIC_DISCOVERY_SEEDS: ${ELASTIC_DISCOVERY_SEEDS}
ELASTICSEARCH_PORT: ${ELASTICSEARCH_PORT}
ES_JAVA_OPTS: -Xmx${ELASTICSEARCH_HEAP} -Xms${ELASTICSEARCH_HEAP} -Des.enforce.bootstrap.checks=true
bootstrap.memory_lock: "true"
volumes:
Expand Down Expand Up @@ -56,6 +57,7 @@ services:
ELASTIC_NODE_NAME: ${ELASTIC_NODE_NAME_2}
ELASTIC_INIT_MASTER_NODE: ${ELASTIC_INIT_MASTER_NODE}
ELASTIC_DISCOVERY_SEEDS: ${ELASTIC_DISCOVERY_SEEDS}
ELASTICSEARCH_PORT: ${ELASTICSEARCH_PORT}
ES_JAVA_OPTS: -Xmx${ELASTICSEARCH_HEAP} -Xms${ELASTICSEARCH_HEAP} -Des.enforce.bootstrap.checks=true
bootstrap.memory_lock: "true"
volumes:
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
ELASTIC_NODE_NAME: ${ELASTIC_NODE_NAME}
ELASTIC_INIT_MASTER_NODE: ${ELASTIC_INIT_MASTER_NODE}
ELASTIC_DISCOVERY_SEEDS: ${ELASTIC_DISCOVERY_SEEDS}
ELASTICSEARCH_PORT: ${ELASTICSEARCH_PORT}
ES_JAVA_OPTS: "-Xmx${ELASTICSEARCH_HEAP} -Xms${ELASTICSEARCH_HEAP} -Des.enforce.bootstrap.checks=true -Dlog4j2.formatMsgNoLookups=true"
bootstrap.memory_lock: "true"
volumes:
Expand All @@ -63,7 +64,7 @@ services:
- source: elasticsearch.key
target: /usr/share/elasticsearch/config/certs/elasticsearch.key
ports:
- "9200:9200"
- "${ELASTICSEARCH_PORT}:${ELASTICSEARCH_PORT}"
- "9300:9300"
ulimits:
memlock:
Expand All @@ -73,7 +74,7 @@ services:
soft: 200000
hard: 200000
healthcheck:
test: ["CMD", "sh", "-c", "curl -sf --insecure https://$ELASTIC_USERNAME:$ELASTIC_PASSWORD@localhost:9200/_cat/health | grep -ioE 'green|yellow' || echo 'not green/yellow cluster status'"]
test: ["CMD", "sh", "-c", "curl -sf --insecure https://$ELASTIC_USERNAME:$ELASTIC_PASSWORD@localhost:$ELASTICSEARCH_PORT/_cat/health | grep -ioE 'green|yellow' || echo 'not green/yellow cluster status'"]

logstash:
image: elastdocker/logstash:${ELK_VERSION}
Expand Down Expand Up @@ -113,6 +114,7 @@ services:
ELASTIC_USERNAME: ${ELASTIC_USERNAME}
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD}
ELASTICSEARCH_HOST_PORT: https://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}
KIBANA_PORT: ${KIBANA_PORT}
env_file:
- ./secrets/.env.kibana.token
secrets:
Expand All @@ -123,7 +125,7 @@ services:
- source: kibana.key
target: /certs/kibana.key
ports:
- "5601:5601"
- "${KIBANA_PORT}:${KIBANA_PORT}"

apm-server:
image: elastdocker/apm-server:${ELK_VERSION}
Expand Down
1 change: 1 addition & 0 deletions elasticsearch/config/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cluster.name: ${ELASTIC_CLUSTER_NAME}
node.name: ${ELASTIC_NODE_NAME}
network.host: 0.0.0.0
transport.host: 0.0.0.0
http.port: ${ELASTICSEARCH_PORT}

## Cluster Settings
discovery.seed_hosts: ${ELASTIC_DISCOVERY_SEEDS}
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/scripts/docker-healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eo pipefail

host="$(hostname --ip-address || echo '127.0.0.1')"

if health="$(curl -fsSL "http://$ELASTIC_USERNAME:$ELASTIC_PASSWORD@$host:9200/_cat/health?h=status")"; then
if health="$(curl -fsSL "https://$ELASTIC_USERNAME:$ELASTIC_PASSWORD@$host:$ELASTICSEARCH_PORT/_cat/health?h=status" --insecure")"; then
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")
if [ "$health" = 'green' ] || [ "$health" = "yellow" ]; then
exit 0
Expand Down
1 change: 1 addition & 0 deletions kibana/config/kibana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
server.name: kibana
server.host: "0.0.0.0"
server.port: ${KIBANA_PORT}

# Elasticsearch Connection
elasticsearch.hosts: [ "${ELASTICSEARCH_HOST_PORT}" ]
Expand Down

0 comments on commit f95e4ff

Please sign in to comment.