Add cronjob for elasticsearch indices cleanup

Elasticsearch pod now has a cron container to run
some jobs for it.

Change-Id: Ia299e662681174512b0ad70b932caf66448b4cea
This commit is contained in:
Proskurin Kirill 2016-09-15 12:48:24 +00:00
parent d865e94bb1
commit 89567d8d14
6 changed files with 68 additions and 1 deletions

View File

@ -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 }}

View File

@ -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"

View File

@ -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:

View File

@ -0,0 +1 @@
@daily root curator --config /etc/curator/curator.yaml /etc/curator/action-delete-indice.yaml

View File

@ -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

View File

@ -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"