Skip to content
Merged
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
42 changes: 37 additions & 5 deletions .github/workflows/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.0.0-SNAPSHOT"]
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.2.0-SNAPSHOT"]
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -23,6 +23,7 @@ jobs:
- name: Start Elasticsearch
uses: ./elasticsearch
with:
security-enabled: false
stack-version: ${{ matrix.elasticsearch }}

- name: Elasticsearch is reachable
Expand All @@ -34,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.0.0-SNAPSHOT"]
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.2.0-SNAPSHOT"]
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -49,6 +50,7 @@ jobs:
- name: Start Elasticsearch
uses: ./elasticsearch
with:
security-enabled: false
stack-version: ${{ matrix.elasticsearch }}
nodes: 3

Expand All @@ -73,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.0.0-SNAPSHOT"]
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.2.0-SNAPSHOT"]
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -88,6 +90,7 @@ jobs:
- name: Start Elasticsearch
uses: ./elasticsearch
with:
security-enabled: false
stack-version: ${{ matrix.elasticsearch }}
port: 9250

Expand All @@ -100,7 +103,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.0.0-SNAPSHOT"]
elasticsearch: ["6.8-SNAPSHOT", "7.x-SNAPSHOT", "8.2.0-SNAPSHOT"]
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -115,6 +118,7 @@ jobs:
- name: Start Elasticsearch
uses: ./elasticsearch
with:
security-enabled: false
stack-version: ${{ matrix.elasticsearch }}
nodes: 3
port: 9250
Expand Down Expand Up @@ -155,11 +159,39 @@ jobs:
- name: Start Elasticsearch
uses: ./elasticsearch
with:
security-enabled: false
stack-version: ${{ matrix.elasticsearch }}
plugins: |
ingest-attachment
analysis-icu

- name: Elasticsearch is reachable
run: |
curl --verbose --show-error http://localhost:9200
curl --verbose --show-error http://localhost:9200

run-action-with-security:
name: Start Elasticsearch with security
runs-on: ubuntu-latest
strategy:
matrix:
elasticsearch: ["8.2.0-SNAPSHOT"]
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144

- name: Start Elasticsearch
uses: ./elasticsearch
with:
stack-version: ${{ matrix.elasticsearch }}

- name: Elasticsearch is reachable
run: |
curl --verbose --show-error -k -u elastic:changeme https://localhost:9200

20 changes: 20 additions & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ___
| Name | Required | Default | Description |
| ------------- | ------------- | ------- | ----- |
| `stack-version` | Yes | | The version of the Elastic Stack you need to use, you can use any version present in [docker.elastic.co](https://www.docker.elastic.co/). |
| `security-enabled` | No | true | Only available in v8. Set to `false` to disable https and basic authentication |
| `nodes` | No | 1 | Number of nodes in the cluster. |
| `port` | No | 9200 | Port where you want to run Elasticsearch. |
| `password` | No | changeme | The password for the user elastic in your cluster |
Expand All @@ -38,6 +39,25 @@ You *must* also add the `Configure sysctl limits` step, otherwise Elasticsearch
stack-version: 7.6.0
```

### Disable security

Disabling security is not recommended, however, for testing purposes, you can do it with:

```yml
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144

- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 8.2.0
security-enabled: false
```

## License

This software is licensed under the [Apache 2 license](./LICENSE).
5 changes: 5 additions & 0 deletions elasticsearch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
stack-version:
description: 'The version of the Elastic Stack you want to run'
required: true
security-enabled:
description: 'Enable or disable HTTPS, enabled by default'
default: 'true'
required: false
nodes:
description: 'Number of nodes in the cluster'
required: false
Expand All @@ -34,3 +38,4 @@ runs:
NODES: ${{ inputs.nodes }}
PORT: ${{ inputs.port }}
PLUGINS: ${{ inputs.plugins }}
SECURITY_ENABLED: ${{ inputs.security-enabled }}
108 changes: 73 additions & 35 deletions elasticsearch/run-elasticsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,82 @@ do
-v /es/plugins/:/usr/share/elasticsearch/plugins/ \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
elif [ "x${MAJOR_VERSION}" == 'x8' ]; then
elasticsearch_password=${elasticsearch_password-'changeme'}
docker run \
--rm \
--env "ELASTIC_PASSWORD=${elasticsearch_password}" \
--env "xpack.security.enabled=true" \
--env "node.name=es${node}" \
--env "cluster.name=docker-elasticsearch" \
--env "cluster.initial_master_nodes=es1" \
--env "discovery.seed_hosts=es1" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--env "bootstrap.memory_lock=true" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "xpack.security.enabled=false" \
--env "xpack.license.self_generated.type=basic" \
--env "http.port=${port}" \
--env "action.destructive_requires_name=false" \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--publish "${port}:${port}" \
--detach \
--network=elastic \
--name="es${node}" \
-v /es/plugins/:/usr/share/elasticsearch/plugins/ \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
if [ "${SECURITY_ENABLED}" == 'true' ]; then
elasticsearch_password=${elasticsearch_password-'changeme'}
docker run \
--rm \
--env "ELASTIC_PASSWORD=${elasticsearch_password}" \
--env "xpack.license.self_generated.type=basic" \
--env "node.name=es${node}" \
--env "cluster.name=docker-elasticsearch" \
--env "cluster.initial_master_nodes=es1" \
--env "discovery.seed_hosts=es1" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--env "bootstrap.memory_lock=true" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "http.port=${port}" \
--env "action.destructive_requires_name=false" \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--publish "${port}:${port}" \
--network=elastic \
--name="es${node}" \
--detach \
-v /es/plugins/:/usr/share/elasticsearch/plugins/ \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
else
docker run \
--rm \
--env "xpack.security.enabled=false" \
--env "node.name=es${node}" \
--env "cluster.name=docker-elasticsearch" \
--env "cluster.initial_master_nodes=es1" \
--env "discovery.seed_hosts=es1" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--env "bootstrap.memory_lock=true" \
--env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
--env "xpack.license.self_generated.type=basic" \
--env "http.port=${port}" \
--env "action.destructive_requires_name=false" \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--publish "${port}:${port}" \
--network=elastic \
--name="es${node}" \
--detach \
-v /es/plugins/:/usr/share/elasticsearch/plugins/ \
docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
fi
fi
done

docker run \
--network elastic \
--rm \
appropriate/curl \
--max-time 120 \
--retry 120 \
--retry-delay 1 \
--retry-connrefused \
--show-error \
--silent \
http://es1:$PORT
if [ "x${MAJOR_VERSION}" == 'x8' ] && [ "${SECURITY_ENABLED}" == 'true' ]; then
docker run \
--network elastic \
--rm \
appropriate/curl \
--max-time 120 \
--retry 120 \
--retry-delay 1 \
--retry-connrefused \
--show-error \
--silent \
-k \
-u elastic:${elasticsearch_password-'changeme'} \
https://es1:$PORT
else
docker run \
--network elastic \
--rm \
appropriate/curl \
--max-time 120 \
--retry 120 \
--retry-delay 1 \
--retry-connrefused \
--show-error \
--silent \
http://es1:$PORT
fi

sleep 10

Expand Down