forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elasticsearch-blueprint.yaml
67 lines (67 loc) · 2.2 KB
/
elasticsearch-blueprint.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
name: elasticsearch-blueprint
actions:
backup:
outputArtifacts:
cloudObject:
keyValue:
backupLocation: "{{ .Phases.backupToObjectStore.Output.backupLocation }}"
phases:
- func: KubeTask
name: backupToObjectStore
args:
namespace: "{{ .StatefulSet.Namespace }}"
image: "ghcr.io/kanisterio/es-sidecar:0.72.0"
command:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
host_name="{{ .Object.spec.serviceName }}.{{ .StatefulSet.Namespace }}.svc.cluster.local"
BACKUP_LOCATION=es_backups/{{ .StatefulSet.Namespace }}/{{ .StatefulSet.Name }}/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15:04:05Z07:00" }}/backup.gz
elasticdump --bulk=true --input=http://${host_name}:9200 --output=/backup
gzip /backup
kando location push --profile '{{ toJson .Profile }}' /backup.gz --path $BACKUP_LOCATION
kando output backupLocation $BACKUP_LOCATION
restore:
inputArtifactNames:
- cloudObject
phases:
- func: KubeTask
name: restoreFromObjectStore
args:
namespace: "{{ .StatefulSet.Namespace }}"
image: "ghcr.io/kanisterio/es-sidecar:0.72.0"
command:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
host_name="{{ .Object.spec.serviceName }}.{{ .StatefulSet.Namespace }}.svc.cluster.local"
kando location pull --profile '{{ toJson .Profile }}' --path '{{ .ArtifactsIn.cloudObject.KeyValue.backupLocation }}' - | gunzip | elasticdump --bulk=true --input=$ --output=http://${host_name}:9200
delete:
inputArtifactNames:
- cloudObject
phases:
- func: KubeTask
name: deleteFromObjectStore
args:
namespace: "{{ .Namespace.Name }}"
image: "ghcr.io/kanisterio/es-sidecar:0.72.0"
command:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
kando location delete --profile '{{ toJson .Profile }}' --path '{{ .ArtifactsIn.cloudObject.KeyValue.backupLocation }}'