forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis-blueprint.yaml
77 lines (77 loc) · 2.84 KB
/
redis-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
68
69
70
71
72
73
74
75
76
77
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
name: redis-blueprint
actions:
backup:
outputArtifacts:
redisCloudDump:
keyValue:
s3path: "{{ .Phases.dumpToObjectStore.Output.s3path }}"
phases:
- func: KubeTask
name: dumpToObjectStore
objects:
redisSecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}'
namespace: '{{ .StatefulSet.Namespace }}'
args:
image: <registry>/<account_name>/redis-tools:<tag_name>
namespace: "{{ .StatefulSet.Namespace }}"
command:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
s3_path="/redis-backups/{{ .StatefulSet.Namespace }}/{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}/dump.sql.gz"
root_password="{{ index .Phases.dumpToObjectStore.Secrets.redisSecret.Data "redis-password" | toString }}"
redis-dump -a ${root_password} -h {{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-{{ index .Object.metadata.labels "app.kubernetes.io/component" }} | gzip - | kando location push --profile '{{ toJson .Profile }}' --path ${s3_path} -
kando output s3path ${s3_path}
restore:
inputArtifactNames:
- redisCloudDump
phases:
- func: KubeTask
name: restoreFromBlobStore
objects:
redisSecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}'
namespace: '{{ .StatefulSet.Namespace }}'
args:
image: <registry>/<account_name>/redis-tools:<tag_name>
namespace: "{{ .StatefulSet.Namespace }}"
command:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
s3_path="{{ .ArtifactsIn.redisCloudDump.KeyValue.s3path }}"
root_password="{{ index .Phases.restoreFromBlobStore.Secrets.redisSecret.Data "redis-password" | toString }}"
kando location pull --profile '{{ toJson .Profile }}' --path ${s3_path} - | gunzip | redis-cli -a ${root_password} -h {{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-{{ index .Object.metadata.labels "app.kubernetes.io/component" }}
delete:
inputArtifactNames:
- redisCloudDump
phases:
- func: KubeTask
name: deleteFromBlobStore
args:
image: <registry>/<account_name>/redis-tools:<tag_name>
namespace: "{{ .Namespace.Name }}"
command:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
s3_path="{{ .ArtifactsIn.redisCloudDump.KeyValue.s3path }}"
kando location delete --profile '{{ toJson .Profile }}' --path ${s3_path}