Add elasticsearch ILM functionality

Add functionality to delete indexes older than 14 days. ILM api
will handle deleting indexes.

Change-Id: I22c02af78b6ce979d0c70b420c106917b0fc5a4e
This commit is contained in:
Graham Steffaniak 2021-01-13 19:43:46 +00:00 committed by gs909v
parent 204c51a669
commit c1241918c2
5 changed files with 32 additions and 2 deletions

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v7.1.0
description: OpenStack-Helm ElasticSearch
name: elasticsearch
version: 0.1.3
version: 0.1.4
home: https://www.elastic.co/
sources:
- https://github.com/elastic/elasticsearch

View File

@ -28,4 +28,18 @@ else
echo "Policy {{$policy_name}} not created!"
fi
{{ end }}
{{ range $policy_name, $fields := .Values.conf.index_policies }}
result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
-XPUT "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_ilm/policy/{{$policy_name}}" \
-H 'Content-Type: application/json' -d @/tmp/{{$policy_name}}.json \
| python -c "import sys, json; print(json.load(sys.stdin)['acknowledged'])")
if [ "$result" == "True" ]; then
echo "Policy {{$policy_name}} created!"
else
echo "Policy {{$policy_name}} not created!"
fi
{{ end }}

View File

@ -28,5 +28,8 @@ data:
{{ range $policy_name, $fields := .Values.conf.snapshot_policies }}
{{ $policy_name }}.json: {{ toJson $fields | b64enc }}
{{ end }}
{{ range $policy_name, $fields := .Values.conf.index_policies }}
{{ $policy_name }}.json: {{ toJson $fields | b64enc }}
{{ end }}
{{- end }}

View File

@ -84,6 +84,12 @@ spec:
subPath: {{$policy_name}}.json
readOnly: true
{{ end }}
{{ range $policy_name, $fields := .Values.conf.index_policies }}
- name: elasticsearch-templates-etc
mountPath: /tmp/{{$policy_name}}.json
subPath: {{$policy_name}}.json
readOnly: true
{{ end }}
{{ if $mounts_elasticsearch_templates.volumeMounts }}{{ toYaml $mounts_elasticsearch_templates.volumeMounts | indent 12 }}{{ end }}
volumes:
- name: pod-tmp

View File

@ -807,7 +807,14 @@ conf:
disable_action: false
retention:
expire_after: 179d
index_policies:
delete_all_indexes:
policy:
phases:
delete:
min_age: 14d
actions:
delete: {}
endpoints:
cluster_domain_suffix: cluster.local
local_image_registry: