Skip to content

Commit

Permalink
Fix ES healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Oct 12, 2023
1 parent c0fb017 commit b571699
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/openchallenges/elasticsearch/docker-healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
# See https://github.com/docker-library/healthcheck/blob/master/elasticsearch/docker-healthcheck
set -eo pipefail

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

if health="$(curl --cacert /usr/share/elasticsearch/config/certs/ca/ca.crt -fsSL "http://$host:9200/_cat/health?h=status")"; then
# Authentication
username="elastic"
password=$ELASTIC_PASSWORD
token=$(echo -n "$username:$password" | openssl base64)

if health="$(curl -H "Authorization: Basic $token" \
--cacert /usr/share/elasticsearch/config/certs/ca/ca.crt \
-fsSL "https://$host:$port/_cat/health?h=status")"; 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
10 changes: 10 additions & 0 deletions docker/openchallenges/services/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ services:
limits:
memory: 2G
depends_on:
openchallenges-elasticsearch-setup:
condition: service_started
openchallenges-elasticsearch-node-2:
condition: service_started
openchallenges-elasticsearch-node-3:
Expand Down Expand Up @@ -107,6 +109,7 @@ services:
- xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/config/certs/openchallenges-elasticsearch-node-2/openchallenges-elasticsearch-node-2.crt
- xpack.security.transport.ssl.key=/usr/share/elasticsearch/config/certs/openchallenges-elasticsearch-node-2/openchallenges-elasticsearch-node-2.key
- xpack.security.audit.enabled=true
- ELASTIC_PASSWORD=changeme
networks:
- openchallenges
volumes:
Expand All @@ -120,6 +123,9 @@ services:
resources:
limits:
memory: 2G
depends_on:
openchallenges-elasticsearch-setup:
condition: service_started

openchallenges-elasticsearch-node-3:
image: ghcr.io/sage-bionetworks/openchallenges-elasticsearch:${OPENCHALLENGES_VERSION:-local}
Expand All @@ -143,6 +149,7 @@ services:
- xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/config/certs/openchallenges-elasticsearch-node-3/openchallenges-elasticsearch-node-3.crt
- xpack.security.transport.ssl.key=/usr/share/elasticsearch/config/certs/openchallenges-elasticsearch-node-3/openchallenges-elasticsearch-node-3.key
- xpack.security.audit.enabled=true
- ELASTIC_PASSWORD=changeme
networks:
- openchallenges
volumes:
Expand All @@ -156,3 +163,6 @@ services:
resources:
limits:
memory: 2G
depends_on:
openchallenges-elasticsearch-setup:
condition: service_started

0 comments on commit b571699

Please sign in to comment.