Simplify curator extension

This commit is contained in:
Antoine Cotten 2020-10-16 19:52:58 +02:00
parent 4676f21ee8
commit 95272b72f4
No known key found for this signature in database
GPG Key ID: 94637E68D4A79DD0
6 changed files with 39 additions and 46 deletions

View File

@ -1,13 +1,17 @@
FROM alpine:3.8 FROM bitnami/elasticsearch-curator:5.8.1
ENV CURATOR_VERSION=5.8.1 USER root
RUN apk --update add --no-cache tini python py-pip \ RUN install_packages cron && \
&& pip install elasticsearch-curator==${CURATOR_VERSION} echo \
'* * * * *' \
root \
LC_ALL=C.UTF-8 LANG=C.UTF-8 \
/opt/bitnami/python/bin/curator \
--config=/usr/share/curator/config/curator.yml \
/usr/share/curator/config/delete_log_files_curator.yml \
'>/proc/1/fd/1' '2>/proc/1/fd/2' \
>>/etc/crontab
COPY entrypoint.sh / ENTRYPOINT ["cron"]
CMD ["-f", "-L8"]
WORKDIR /usr/share/curator
COPY config ./config
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -11,8 +11,10 @@ command line argument referencing the `curator-compose.yml` file:
$ docker-compose -f docker-compose.yml -f extensions/curator/curator-compose.yml up $ docker-compose -f docker-compose.yml -f extensions/curator/curator-compose.yml up
``` ```
This sample setup demonstrates how to run `curator` every minute using `cron`.
All configuration files are available in the `config/` directory. All configuration files are available in the `config/` directory.
## Documentation ## Documentation
https://github.com/elastic/curator https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

View File

@ -1,24 +1,12 @@
--- # Curator configuration
# Remember, leave a key empty if there is no value. None will be a string, # https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html
# not a Python "NoneType"
client: client:
hosts: hosts:
- ${ELASTICSEARCH_HOST} - elasticsearch
port: 9200 port: 9200
url_prefix: http_auth: elastic:changeme
use_ssl: False
certificate:
client_cert:
client_key:
aws_key:
aws_secret_key:
aws_region:
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
logging: logging:
loglevel: DEBUG loglevel: INFO
logfile:
logformat: default logformat: default

View File

@ -2,10 +2,11 @@ actions:
1: 1:
action: delete_indices action: delete_indices
description: >- description: >-
Delete indices. Find which to delete by first limiting the list to logstash- Delete indices. Find which to delete by first limiting the list to
prefixed indices. Then further filter those to prevent deletion of anything logstash- prefixed indices. Then further filter those to prevent deletion
less than ${UNIT_COUNT} days old. Ignore the error if the filter does not result in an of anything less than the number of days specified by unit_count.
actionable list of indices (ignore_empty_list) and exit cleanly. Ignore the error if the filter does not result in an actionable list of
indices (ignore_empty_list) and exit cleanly.
options: options:
ignore_empty_list: True ignore_empty_list: True
disable_action: False disable_action: False
@ -17,4 +18,4 @@ actions:
source: creation_date source: creation_date
direction: older direction: older
unit: days unit: days
unit_count: ${UNIT_COUNT} unit_count: 2

View File

@ -4,12 +4,16 @@ services:
curator: curator:
build: build:
context: extensions/curator/ context: extensions/curator/
environment: init: true
ELASTICSEARCH_HOST: elasticsearch volumes:
CRON: 0 0 * * * - type: bind
CONFIG_FILE: /usr/share/curator/config/curator.yml source: ./extensions/curator/config/curator.yml
COMMAND: /usr/share/curator/config/delete_log_files_curator.yml target: /usr/share/curator/config/curator.yml
UNIT_COUNT: 2 read_only: true
- type: bind
source: ./extensions/curator/config/delete_log_files_curator.yml
target: /usr/share/curator/config/delete_log_files_curator.yml
read_only: true
networks: networks:
- elk - elk
depends_on: depends_on:

View File

@ -1,6 +0,0 @@
#!/bin/sh
echo "$CRON /usr/bin/curator --config ${CONFIG_FILE} ${COMMAND}" >>/etc/crontabs/root
# https://github.com/krallin/tini/blob/master/README.md#subreaping
tini -s -- crond -f -d 8 -l 8