Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

Allow modifying elasticsearch.yml using environment variables #52

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ This image can be configured by means of environment variables, that one can set
* [MEMORY_LOCK](https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html#bootstrap.memory_lock) - memory locking control - enable to prevent swap (default = `true`) .
* [REPO_LOCATIONS](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html#_shared_file_system_repository) - list of registered repository locations. For example `["/backup"]` (default = `[]`).
* [PROCESSORS](https://github.com/elastic/elasticsearch-definitive-guide/pull/679/files) - allow elasticsearch to optimize for the actual number of available cpus (must be an integer - default = 1)
* ES_CONFIG_* - add any entries to elasticsearch.yml by prodiving multiple variables. Double underscore will be replaced with dots, e.g. ES_CONFIG_S3__CLIENT__MINIO__PROTOCOL='http' ends up as s3.client.minio.protocol: http
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be properly documented in a separate section.

* [ES_KEYSTORE_*](https://www.elastic.co/guide/en/elasticsearch/reference/current/secure-settings.html) - add any ES Keystore items by adding a new environment variable. Double underscore will be replaced with dots, e.g. ES_KEYSTORE_S3__CLIENT__DEFAULT__ACCESS_KEY ends up as s3.client.default.access_key

### Backup
Mount a shared folder (for example via NFS) to `/backup` and make sure the `elasticsearch` user
Expand Down
23 changes: 22 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

BASE=/elasticsearch

Expand Down Expand Up @@ -40,7 +40,28 @@ if [ ! -z "${SHARD_ALLOCATION_AWARENESS_ATTR}" ]; then
fi
fi

for item in ${!ES_CONFIG_*}; do
value=${!item}
item=${item##ES_CONFIG_} # Strip away prefix
item=${item,,} # Lowercase
item=${item//__/.} # Replace double underscore with dot
echo "${item}: ${value}" >> $BASE/config/elasticsearch.yml
done

# run
chown -R elasticsearch:elasticsearch $BASE

for item in ${!ES_KEYSTORE_*}; do
value=${!item}
item=${item##ES_KEYSTORE_} # Strip away prefix
item=${item,,} # Lowercase
item=${item//__/.} # Replace double underscore with dot

if [ ! -f $BASE/config/elasticsearch.keystore ]; then
su-exec elasticsearch $BASE/bin/elasticsearch-keystore create
fi
su-exec elasticsearch $BASE/bin/elasticsearch-keystore add -x $item <<< ${value}
done

chown -R elasticsearch:elasticsearch /data
exec su-exec elasticsearch $BASE/bin/elasticsearch