-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from james-r-hmlr/elasticsearch7
Added elasticsearch7 commodity
- Loading branch information
Showing
7 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.24 | ||
|
||
ENV ES_JAVA_OPTS -Xms1024m -Xmx1024m | ||
ENV discovery.type single-node | ||
|
||
# Remove default heap size and add low-memory optimisations | ||
RUN echo "bootstrap.memory_lock: true" >> /usr/share/elasticsearch/config/elasticsearch.yml && \ | ||
echo "indices.fielddata.cache.size: 50%" >> /usr/share/elasticsearch/config/elasticsearch.yml && \ | ||
echo "indices.memory.index_buffer_size: 50%" >> /usr/share/elasticsearch/config/elasticsearch.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
services: | ||
elasticsearch7: | ||
container_name: elasticsearch7 | ||
build: ../scripts/docker/elasticsearch7 | ||
ports: | ||
- "9207:9200" | ||
- "9307:9300" | ||
# restart: on-failure | ||
platform: "linux/amd64" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
nofile: | ||
soft: 65536 | ||
hard: 65536 | ||
cap_add: | ||
- IPC_LOCK |
18 changes: 18 additions & 0 deletions
18
scripts/docker/elasticsearch7/docker-compose-fragment.3.7.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.7' | ||
services: | ||
elasticsearch7: | ||
container_name: elasticsearch7 | ||
build: ../scripts/docker/elasticsearch7 | ||
ports: | ||
- "9207:9200" | ||
- "9307:9300" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
nofile: | ||
soft: 65536 | ||
hard: 65536 | ||
cap_add: | ||
- IPC_LOCK | ||
restart: on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: '2' | ||
services: | ||
elasticsearch7: | ||
container_name: elasticsearch7 | ||
build: ../scripts/docker/elasticsearch7 | ||
ports: | ||
- "9207:9200" | ||
- "9307:9300" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
nofile: | ||
soft: 65536 | ||
hard: 65536 | ||
mem_limit: 2048m | ||
cap_add: | ||
- IPC_LOCK | ||
restart: on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require_relative 'utilities' | ||
require_relative 'commodities' | ||
require 'yaml' | ||
|
||
def provision_elasticsearch7(root_loc) | ||
puts colorize_lightblue('Searching for elasticsearch7 initialisation scripts in the apps') | ||
|
||
# Load configuration.yml into a Hash | ||
config = YAML.load_file("#{root_loc}/dev-env-config/configuration.yml") | ||
started = false | ||
return unless config['applications'] | ||
|
||
config['applications'].each_key do |appname| | ||
# To help enforce the accuracy of the app's dependency file, only search for init scripts | ||
# if the app specifically specifies elasticsearch in it's commodity list | ||
next unless File.exist?("#{root_loc}/apps/#{appname}/configuration.yml") | ||
next unless commodity_required?(root_loc, appname, 'elasticsearch7') | ||
|
||
# Run any script contained in the app | ||
if File.exist?("#{root_loc}/apps/#{appname}/fragments/elasticsearch7-fragment.sh") | ||
started = start_elasticsearch7(root_loc, appname, started) | ||
else | ||
puts colorize_yellow("#{appname} says it uses Elasticsearch 7 but doesn't contain an init script. Oh well, " \ | ||
'onwards we go!') | ||
end | ||
end | ||
end | ||
|
||
def start_elasticsearch7(root_loc, appname, started) | ||
puts colorize_pink("Found some in #{appname}") | ||
if commodity_provisioned?(root_loc, appname, 'elasticsearch7') | ||
puts colorize_yellow("Elasticsearch7 has previously been provisioned for #{appname}, skipping") | ||
else | ||
unless started | ||
run_command("#{ENV['DC_CMD']} up -d elasticsearch7") | ||
# Better not run anything until elasticsearch is ready to accept connections... | ||
puts colorize_lightblue('Waiting for Elasticsearch 7 to finish initialising') | ||
|
||
loop do | ||
cmd_output = [] | ||
run_command('curl --write-out "%{http_code}" --silent --output /dev/null http://localhost:9202', cmd_output) | ||
break if cmd_output.include? '200' | ||
|
||
puts colorize_yellow('Elasticsearch 7 is unavailable - sleeping') | ||
sleep(3) | ||
end | ||
|
||
puts colorize_green('Elasticsearch 7 is ready') | ||
started = true | ||
end | ||
run_command("sh #{root_loc}/apps/#{appname}/fragments/elasticsearch7-fragment.sh http://localhost:9202") | ||
# Update the .commodities.yml to indicate that elasticsearch7 has now been provisioned | ||
set_commodity_provision_status(root_loc, appname, 'elasticsearch7', true) | ||
end | ||
started | ||
end |