diff --git a/.env b/.env new file mode 100644 index 0000000000000000000000000000000000000000..6db1ca6fc521c5897b3d6625baedf17f17beca52 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME=es diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f92da7b142f506a53baa2e4028ac3e501c5919d9..6fb7498b5d0ee15df7bea9d9e724aa8676d402e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,3 +2,25 @@ include: - project: shore/ci-templates file: templates/pre-commit.yml + - project: shore/ci-templates + file: templates/docker.yml + +stages: + - test + - build + - deploy + +build: + extends: .compose-build + tags: &tags [host01.shore.co.il] + variables: + DOCKER_BUILDKIT: "" + COMPOSE_DOCKER_CLI_BUILD: "" + +pull: + extends: .compose-pull + tags: *tags + +run: + extends: .compose-run + tags: *tags diff --git a/curator/.dockerignore b/curator/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..8e16f591dab86288234797b22c68df725f91dd8c --- /dev/null +++ b/curator/.dockerignore @@ -0,0 +1,4 @@ +* +!crontab +!config.yml +!actions.yml diff --git a/curator/Dockerfile b/curator/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..51931e4aad97edbde87dee97cccbaf2dc58c3d40 --- /dev/null +++ b/curator/Dockerfile @@ -0,0 +1,8 @@ +# hadolint ignore=DL3006 +FROM registry.shore.co.il/cron +USER root +# hadolint ignore=DL3018 +RUN apk add --update --no-cache py3-pip +RUN python3 -m pip install --no-cache-dir elasticsearch-curator==5.8.4 +USER nobody +COPY --chown=root:root config.yml actions.yml /etc/curator/ diff --git a/curator/actions.yml b/curator/actions.yml new file mode 100644 index 0000000000000000000000000000000000000000..321f92027eb31c82c72fb38060abe3aee1ca43b5 --- /dev/null +++ b/curator/actions.yml @@ -0,0 +1,16 @@ +--- +actions: + 1: + action: delete_indices + description: Delete old indices + ignore_empty_list: True + filters: + - filtertype: pattern + kind: timestring + value: '%Y.%m.%d' + - filtertype: age + source: name + direction: older + timestring: '%Y.%m.%d' + unit: days + unit_count: 3 diff --git a/curator/config.yml b/curator/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..1481ff4515e7ccbb135b345375e93af7c72110e4 --- /dev/null +++ b/curator/config.yml @@ -0,0 +1,4 @@ +--- +client: + hosts: + - elasticsearch diff --git a/curator/crontab b/curator/crontab new file mode 100644 index 0000000000000000000000000000000000000000..5fb2a0ce675549f04e91f1c017f490104187494c --- /dev/null +++ b/curator/crontab @@ -0,0 +1 @@ +0 3 * * * curator --config /etc/curator/config.yml /etc/curator/actions.yml || wget --spider https://notify.shore.co.il/send?message=Elasticsearch%20curator%20failed. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..291d59d405f42b635835d2f41d5d704841c84366 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +--- +version: '3.7' +services: + curator: + build: + context: curator + links: + - elasticsearch + restart: always + + elasticsearch: + environment: + 'node.name': elasticsearch.shore.co.il + 'cluster.name': shore.co.il + 'discovery.type': single-node + ES_JAVA_OPTS: "-Xms512m -Xmx512m" + healthcheck: + test: ["CMD", "curl", "--fail", "http://localhost:9200/_cat/health"] + image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2 + restart: always + volumes: + - elasticsearch:/usr/share/elasticsearch/data + + kibana: + environment: + ELASTICSEARCH_HOSTS: | + ["http://elasticsearch:9200"] + TELEMETARY_OPTIN: !!str false + healthcheck: + test: ["CMD", "curl", "--fail", "http://localhost:5601/api/status"] + image: docker.elastic.co/kibana/kibana-oss:7.10.2 + links: + - elasticsearch + restart: always + +volumes: + elasticsearch: + +networks: + default: + name: shore