forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
couchbase-blueprint.yaml
92 lines (90 loc) · 3.43 KB
/
couchbase-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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
name: couchbase-blueprint
actions:
backup:
kind: CustomResource
outputArtifacts:
cbBackup:
keyValue:
path: '/couchbase-backups/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}/backup.tgz'
phases:
- func: KubeTask
name: TakeBackup
objects:
authSecret:
kind: Secret
name: "{{ .Object.spec.security.adminSecret }}"
namespace: "{{ .Object.metadata.namespace }}"
args:
namespace: "{{ .Object.metadata.namespace }}"
image: ghcr.io/kanisterio/couchbase-tools:0.22.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
rm -rf /backups/test
mkdir -p /backups/test
cbbackupmgr config --archive /backups/test --repo couchbase
cbbackupmgr backup \
--archive /backups/test \
--repo couchbase \
--cluster couchbase://{{ .Object.metadata.name }}.{{ .Object.metadata.namespace }}.svc \
--username {{ .Phases.TakeBackup.Secrets.authSecret.Data.username | toString }} \
--password {{ .Phases.TakeBackup.Secrets.authSecret.Data.password | toString }}
tar zcvf - -C /backups/ test | kando location push --profile '{{ toJson .Profile }}' --path '/couchbase-backups/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}/backup.tgz' -
restore:
kind: CustomResource
inputArtifactNames:
- cbBackup
phases:
- func: KubeTask
name: restoreBackup
objects:
authSecret:
kind: Secret
name: "{{ .Object.spec.security.adminSecret }}"
namespace: "{{ .Object.metadata.namespace }}"
args:
namespace: "{{ .Object.metadata.namespace }}"
image: ghcr.io/kanisterio/couchbase-tools:0.22.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
rm -rf /backups/test
mkdir -p /backups/test
kando location pull --profile '{{ toJson .Profile }}' --path '{{ .ArtifactsIn.cbBackup.KeyValue.path }}' - | tar zxvf - -C /backups/
cbbackupmgr restore \
--archive /backups/test \
--repo couchbase \
--cluster couchbase://{{ .Object.metadata.name }}.{{ .Object.metadata.namespace }}.svc \
--username {{ .Phases.restoreBackup.Secrets.authSecret.Data.username | toString }} \
--password {{ .Phases.restoreBackup.Secrets.authSecret.Data.password | toString }} \
--force-updates
delete:
phases:
- func: KubeTask
name: deleteBackup
args:
namespace: "{{ .Namespace.Name }}"
image: ghcr.io/kanisterio/kanister-tools:0.72.0
command:
- bash
- -o
- pipefail
- -o
- errexit
- -c
- |
s3path='{{ .ArtifactsIn.cbBackup.KeyValue.path }}'
kando location delete --profile '{{ toJson .Profile }}' --path ${s3path}