Director of Cloud Engineering @ Team8Solutions, Freelancer
Kubernetes- Elasticsearch Scheduled Backup and Retention Using Curator
This post will guide you to create a scheduled elasticsearch backup using curator in k8s cluster.
Assumptions:
1234
You already have a 6.x.x elasticsearch k8s cluster
You already have a backup system
You are some what familiar with Kubernetes
You are familiar with curator configs
Step 1: Create a configmap with curator yml
12
Action 1 will create a snapshot
Action 2 will keep last 20 days snapshots and delete that are older than 20 days
apiVersion: v1
kind: ConfigMap
metadata:
name: curator-config
labels:
app: curator
data:
backup.yml: |-
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: snapshot
description: "Create snapshot"
options:
repository: "primary_backup"
continue_if_exception: False
wait_for_completion: True
filters:
- filtertype: pattern
kind: regex
value: ".*$"
2:
action: delete_snapshots
description: >-
Delete snapshots from the selected repository older than 10 days
(based on creation_date), for 'curator-' prefixed snapshots.
options:
repository: "primary_backup"
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: curator-
exclude:
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 20
config.yml: |-
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
client:
hosts:
- elasticsearch
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
logging:
loglevel: DEBUG
Step 2: Create a config map in your kubernetes cluster