Skip to content

Commit

Permalink
disable SSL/TLS in elastic search, integrate es with backendnext
Browse files Browse the repository at this point in the history
  • Loading branch information
consolethinks committed Apr 9, 2024
1 parent 79f2a61 commit ad24ecb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 75 deletions.
10 changes: 10 additions & 0 deletions services/backendnext/config/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ DELETE_GROUPS=buggy
CREATE_DATASET_GROUPS=ingestor
PROPOSAL_GROUPS=proposalingestor
SAMPLE_GROUPS=ingestor

ELASTICSEARCH_ENABLE=yes
ES_HOST="http://elastic:9200"
ES_USERNAME="elastic"
ES_PASSWORD="password"
MONGODB_COLLECTION="elastic"
ES_MAX_RESULT=10000
ES_FIELDS_LIMIT=1000
ES_INDEX="dataset"
ES_REFRESH="false"
5 changes: 4 additions & 1 deletion services/backendnext/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ services:
backendnext:
image: ghcr.io/scicatproject/backend-next:v4.4.0
depends_on:
- mongodb
mongodb:
condition: service_started
elastic:
condition: service_healthy
volumes:
- ./config/functionalAccounts.json:/home/node/app/functionalAccounts.json
env_file:
Expand Down
13 changes: 3 additions & 10 deletions services/elastic/config/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ cluster.name=docker-cluster
cluster.initial_master_nodes=es01
ELASTIC_PASSWORD="password"
bootstrap.memory_lock=true
xpack.security.enabled=true
xpack.security.http.ssl.enabled=true
xpack.security.http.ssl.key=certs/es01/es01.key
xpack.security.http.ssl.certificate=certs/es01/es01.crt
xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
xpack.security.transport.ssl.enabled=true
xpack.security.transport.ssl.key=certs/es01/es01.key
xpack.security.transport.ssl.certificate=certs/es01/es01.crt
xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
xpack.security.transport.ssl.verification_mode=certificate
xpack.security.enabled=false
xpack.security.http.ssl.enabled=false
xpack.security.transport.ssl.enabled=false
xpack.license.self_generated.type=basic
72 changes: 8 additions & 64 deletions services/elastic/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,13 @@
version: '2.2'

services:
setup:
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.1
volumes:
- certs:/usr/share/elasticsearch/config/certs
user: '0'
command: >
bash -c '
export ELASTIC_PASSWORD=password;
if [ x${ELASTIC_PASSWORD} == x ]; then
echo "Set the ELASTIC_PASSWORD environment variable in the .env file";
exit 1;
fi;
if [ ! -f config/certs/ca.zip ]; then
echo "Creating CA";
bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip;
unzip config/certs/ca.zip -d config/certs;
fi;
if [ ! -f config/certs/certs.zip ]; then
echo "Creating certs";
echo -ne \
"instances:\n"\
" - name: es01\n"\
" dns:\n"\
" - es01\n"\
" - localhost\n"\
" ip:\n"\
" - 127.0.0.1\n"\
> config/certs/instances.yml;
bin/elasticsearch-certutil cert --silent --pem -out
config/certs/certs.zip --in config/certs/instances.yml
--ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
unzip config/certs/certs.zip -d config/certs;
fi;
echo "Setting file permissions"
chown -R root:root config/certs;
find . -type d -exec chmod 750 \{\} \;;
find . -type f -exec chmod 640 \{\} \;;
echo "Waiting for Elasticsearch availability";
until curl -s --cacert config/certs/ca/ca.crt https://es01:9200 | grep
-q "missing authentication credentials"; do sleep 30; done;
echo "All done!";
'
healthcheck:
test: [CMD-SHELL, '[ -f config/certs/es01/es01.crt ]']
interval: 1s
timeout: 5s
retries: 120
env_file:
- ./config/.env

es01:
depends_on:
setup:
condition: service_healthy
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.1
volumes:
- certs:/usr/share/elasticsearch/config/certs
- esdata01:/usr/share/elasticsearch/data
- esdata:/usr/share/elasticsearch/data
labels:
- traefik.http.routers.es01.rule=Host(`elastic.localhost`)
- traefik.http.services.es01.loadbalancer.server.port=9200
- traefik.http.routers.elastic.rule=Host(`elastic.localhost`)
- traefik.http.services.elastic.loadbalancer.server.port=9200
mem_limit: 1073741824
ulimits:
memlock:
Expand All @@ -71,17 +17,15 @@ services:
test:
[
CMD-SHELL,
curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 |
grep -q 'missing authentication credentials',
'curl -f localhost:9200 | grep -q
''"tagline" : "You Know, for Search"'''
]
interval: 10s
timeout: 10s
retries: 120
retries: 15
env_file:
- ./config/.env

volumes:
certs:
driver: local
esdata01:
esdata:
driver: local

0 comments on commit ad24ecb

Please sign in to comment.