diff --git a/docker/cron/Dockerfile.j2 b/docker/cron/Dockerfile.j2 index bb3b2ef..e05a104 100644 --- a/docker/cron/Dockerfile.j2 +++ b/docker/cron/Dockerfile.j2 @@ -5,4 +5,5 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get -y install --no-install-recommends \ cron \ logrotate \ - && apt-get clean + && apt-get clean \ + && pip install --no-cache-dir elasticsearch-curator=={{ elasticsearch_curator_version }} diff --git a/service/elasticsearch.yaml b/service/elasticsearch.yaml index d5e6de4..3e17b42 100644 --- a/service/elasticsearch.yaml +++ b/service/elasticsearch.yaml @@ -13,7 +13,28 @@ service: command: /usr/share/elasticsearch/bin/elasticsearch files: - elasticsearch.yml + - name: cron + image: cron + probes: + readiness: "true" + liveness: "true" + daemon: + command: cron -f + files: + - es-curator-config + - es-curator-action-delete-indice + - es-curator-cronjob files: elasticsearch.yml: path: /usr/share/elasticsearch/config/elasticsearch.yml content: elasticsearch.yml.j2 + es-curator-config: + path: /etc/curator/curator.yaml + content: curator.yaml.j2 + es-curator-action-delete-indice: + path: /etc/curator/action-delete-indice.yaml + content: curator-action-delete-indice.yaml.j2 + es-curator-cronjob: + path: /etc/cron.d/curator + content: curator-cronjob + perm: "0644" diff --git a/service/files/curator-action-delete-indice.yaml.j2 b/service/files/curator-action-delete-indice.yaml.j2 new file mode 100644 index 0000000..bd9d524 --- /dev/null +++ b/service/files/curator-action-delete-indice.yaml.j2 @@ -0,0 +1,29 @@ +--- +# Remember, leave a key empty if there is no value. None will be a string, +# not a Python "NoneType" +actions: + 1: + action: delete_indices + description: >- + Delete indices older than {{ elasticsearch_retention_period }} days + (based on index name), for 'log-' prefixed indices. Ignore the error + if the filter does not result in an actionable list of indices + (ignore_empty_list) and exit cleanly. + options: + ignore_empty_list: True + timeout_override: + continue_if_exception: False + disable_action: False + filters: + - filtertype: pattern + kind: prefix + value: log- + exclude: + - filtertype: age + source: name + direction: older + timestring: '%Y.%m.%d' + unit: days + unit_count: {{ elasticsearch_retention_period }} + exclude: + diff --git a/service/files/curator-cronjob b/service/files/curator-cronjob new file mode 100644 index 0000000..9bfc7b7 --- /dev/null +++ b/service/files/curator-cronjob @@ -0,0 +1 @@ +@daily root curator --config /etc/curator/curator.yaml /etc/curator/action-delete-indice.yaml diff --git a/service/files/curator.yaml.j2 b/service/files/curator.yaml.j2 new file mode 100644 index 0000000..6879eb3 --- /dev/null +++ b/service/files/curator.yaml.j2 @@ -0,0 +1,13 @@ +--- +# Remember, leave a key empty if there is no value. None will be a string, +# not a Python "NoneType" +client: + hosts: + - localhost + port: {{ elasticsearch_port }} + url_prefix: + use_ssl: False + certificate: + ssl_no_validate: False + timeout: 30 + master_only: True diff --git a/service/files/defaults.yaml b/service/files/defaults.yaml index 380ec7b..fd5a2a0 100644 --- a/service/files/defaults.yaml +++ b/service/files/defaults.yaml @@ -1,6 +1,7 @@ configs: elasticsearch_port: 9200 elasticsearch_cluster_port: 9300 + elasticsearch_retention_period: 30 kibana_port: 5601 heka_max_procs: 2 heka_service_pattern: "^k8s_(.-)%..*" @@ -24,3 +25,4 @@ versions: grafana_version: "3.0.3-1463994644" elasticsearch_version: "2.4.0" kibana_version: "4.6.1" + elasticsearch_curator_version: "4.1.0"