Skip to content

Commit 3875d47

Browse files
committed
add support for kopia maintenance + persistent kopia home dir
1 parent 18b7f08 commit 3875d47

8 files changed

Lines changed: 90 additions & 3 deletions

apps/storage/templates/_helpers.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ volumeMounts:
5353
mountPath: /dev
5454
- name: host-modules
5555
mountPath: /lib/modules
56+
- name: home
57+
mountPath: /root
5658
command: [bash]
5759
{{- end }}
5860

@@ -68,6 +70,5 @@ command: [bash]
6870
keyring = /etc/ceph/keyring" > /etc/ceph/ceph.conf
6971
echo "[${ROOK_CEPH_USERNAME}]
7072
key = ${ROOK_CEPH_KEYRING}" > /etc/ceph/keyring
71-
kopia repository connect s3 --bucket=$KOPIA_S3_BUCKET --region=$KOPIA_S3_REGION
7273
) 2>&1 | tee /tmp/log.txt
7374
{{- end }}

apps/storage/templates/hasadna-k8s-pvc-backup-all-workflow-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
tasks:
1212
- name: runner
1313
templateRef:
14-
name: runner
14+
name: kopia-runner
1515
template: script
1616
arguments:
1717
parameters:

apps/storage/templates/hasadna-k8s-pvc-backup-workflow-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
tasks:
1919
- name: runner
2020
templateRef:
21-
name: runner
21+
name: kopia-runner
2222
template: script
2323
arguments:
2424
parameters:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: CronWorkflow
3+
metadata:
4+
name: hasadna-k8s-pvc-maintenance-hourly
5+
spec:
6+
schedule: "11 * * * *"
7+
suspend: false
8+
concurrencyPolicy: Forbid
9+
workflowSpec:
10+
workflowTemplateRef:
11+
name: hasadna-k8s-pvc-maintenance
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: WorkflowTemplate
3+
metadata:
4+
name: hasadna-k8s-pvc-maintenance
5+
spec:
6+
entrypoint: dag
7+
arguments:
8+
templates:
9+
- name: dag
10+
dag:
11+
tasks:
12+
- name: runner
13+
templateRef:
14+
name: kopia-runner
15+
template: script
16+
arguments:
17+
parameters:
18+
- name: exec_script
19+
value: |
20+
hasadna-k8s ceph maintenance
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: WorkflowTemplate
3+
metadata:
4+
name: kopia-runner
5+
spec:
6+
synchronization:
7+
mutexes:
8+
- name: kopia-runner-mutex
9+
arguments:
10+
parameters:
11+
- name: exec_script
12+
default: "kopia repository status"
13+
entrypoint: dag
14+
templates:
15+
- name: dag
16+
dag:
17+
tasks:
18+
- name: script
19+
template: script
20+
arguments:
21+
parameters:
22+
- name: exec_script
23+
value: |
24+
{{ "{{workflow.parameters.exec_script}}" }}
25+
- name: script
26+
serviceAccountName: workflow-runner
27+
inputs:
28+
parameters:
29+
- name: exec_script
30+
volumes: {{ include "runner.volumes" . | nindent 8 }}
31+
- name: home
32+
persistentVolumeClaim:
33+
claimName: kopia-home
34+
script:
35+
source: {{ include "runner.script" . | nindent 8 }}
36+
cat <<'EOF' > /tmp/exec_script.sh
37+
kopia repository connect s3 --bucket=$KOPIA_S3_BUCKET --region=$KOPIA_S3_REGION
38+
{{ "{{inputs.parameters.exec_script}}" }}
39+
EOF
40+
chmod +x /tmp/exec_script.sh
41+
/tmp/exec_script.sh 2>&1 | tee /tmp/log.txt
42+
echo "Execution completed successfully" 2>&1 | tee /tmp/log.txt
43+
securityContext:
44+
privileged: true
45+
runAsUser: 0
46+
{{ include "runner.container" . | indent 8 }}
47+
outputs:
48+
parameters:
49+
- name: log
50+
valueFrom:
51+
path: /tmp/log.txt

apps/storage/templates/runner-workflow-template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ spec:
2525
parameters:
2626
- name: exec_script
2727
volumes: {{ include "runner.volumes" . | nindent 8 }}
28+
- name: home
29+
emptyDir: {}
2830
script:
2931
source: {{ include "runner.script" . | nindent 8 }}
3032
cat <<'EOF' > /tmp/exec_script.sh

apps/storage/templates/toolbox-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ spec:
1313
app: rook-ceph-toolbox
1414
spec:
1515
volumes: {{ include "runner.volumes" . | nindent 8 }}
16+
- name: home
17+
emptyDir: {}
1618
containers:
1719
- name: toolbox
1820
{{ include "runner.container" . | indent 10 }}

0 commit comments

Comments
 (0)