forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8ssandra-blueprint.yaml
115 lines (115 loc) · 4.45 KB
/
k8ssandra-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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
name: k8ssandra-blueprint
actions:
backup:
outputArtifacts:
backupInfo:
keyValue:
apiVersion: '{{ .Phases.createCassandraBackup.Output.apiVersion }}'
group: '{{ .Phases.createCassandraBackup.Output.group }}'
name: '{{ .Phases.createCassandraBackup.Output.name }}'
namespace: '{{ .Phases.createCassandraBackup.Output.namespace }}'
resource: '{{ .Phases.createCassandraBackup.Output.resource }}'
phases:
# Create CassandraBackup CR
- func: KubeOps
name: createCassandraBackup
args:
operation: create
namespace: '{{ .Object.metadata.namespace }}'
spec: |-
apiVersion: cassandra.k8ssandra.io/v1alpha1
kind: CassandraBackup
metadata:
name: kanister-{{ .Object.spec.clusterName }}-{{ .Object.metadata.name }}-{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02t15-04-05" }}
spec:
name: kanister-{{ .Object.spec.clusterName }}-{{ .Object.metadata.name }}-{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02t15-04-05" }}
cassandraDatacenter: "{{ .Object.metadata.name }}"
- func: Wait
name: waitCassandraBackupComplete
args:
timeout: 45m
conditions:
anyOf:
- condition: |-
{{ if "{$.status.finishTime}" }}
{{ if "{$.status.finished[]}" }}
true
{{ end }}
{{ else }}
false
{{ end }}
objectReference:
apiVersion: '{{ .Phases.createCassandraBackup.Output.apiVersion }}'
group: '{{ .Phases.createCassandraBackup.Output.group }}'
name: '{{ .Phases.createCassandraBackup.Output.name }}'
namespace: '{{ .Phases.createCassandraBackup.Output.namespace }}'
resource: '{{ .Phases.createCassandraBackup.Output.resource }}'
restore:
inputArtifactNames:
- backupInfo
phases:
# Create CassandraRestore CR
- func: KubeOps
name: createCassandraRestore
args:
namespace: '{{ .Object.metadata.namespace }}'
operation: create
spec: |-
apiVersion: cassandra.k8ssandra.io/v1alpha1
kind: CassandraRestore
metadata:
name: restore-{{ .ArtifactsIn.backupInfo.KeyValue.name }}
spec:
backup: {{ .ArtifactsIn.backupInfo.KeyValue.name }}
inPlace: true
shutdown: true
cassandraDatacenter:
name: "{{ .Object.metadata.name }}"
clusterName: "{{ .Object.spec.clusterName }}"
- func: Wait
name: waitCassandraRestoreComplete
args:
timeout: 600m
conditions:
anyOf:
- condition: |-
{{ if "{$.status.finishTime}" }}
{{ if "{$.status.restoreKey}" }}
true
{{ end }}
{{ else }}
false
{{ end }}
objectReference:
apiVersion: '{{ .Phases.createCassandraRestore.Output.apiVersion }}'
group: '{{ .Phases.createCassandraRestore.Output.group }}'
name: '{{ .Phases.createCassandraRestore.Output.name }}'
namespace: '{{ .Phases.createCassandraRestore.Output.namespace }}'
resource: '{{ .Phases.createCassandraRestore.Output.resource }}'
- func: KubeOps
name: cassandraRestoreDelete
args:
operation: delete
objectReference:
apiVersion: '{{ .Phases.createCassandraRestore.Output.apiVersion }}'
group: '{{ .Phases.createCassandraRestore.Output.group }}'
name: '{{ .Phases.createCassandraRestore.Output.name }}'
namespace: '{{ .Phases.createCassandraRestore.Output.namespace }}'
resource: '{{ .Phases.createCassandraRestore.Output.resource }}'
delete:
inputArtifactNames:
- backupInfo
phases:
- func: KubeOps
name: cassandraBackupDelete
args:
operation: delete
objectReference:
apiVersion: '{{ .ArtifactsIn.backupInfo.KeyValue.apiVersion }}'
group: '{{ .ArtifactsIn.backupInfo.KeyValue.group }}'
name: '{{ .ArtifactsIn.backupInfo.KeyValue.name }}'
namespace: '{{ .ArtifactsIn.backupInfo.KeyValue.namespace }}'
resource: '{{ .ArtifactsIn.backupInfo.KeyValue.resource }}'