|
| 1 | +{{- $etcdReplicas := int (default 1 .Values.vcluster.controlPlane.backingStore.etcd.deploy.statefulSet.highAvailability.replicas) }} |
| 2 | +{{- range $i := until $etcdReplicas }} |
| 3 | +{{- $volume := printf "data-workflows-cluster-etcd-%d" $i }} |
| 4 | +--- |
| 5 | +apiVersion: batch/v1 |
| 6 | +kind: CronJob |
| 7 | +metadata: |
| 8 | + name: "restore-etcd-{{ $i }}" |
| 9 | +spec: |
| 10 | + schedule: "@yearly" |
| 11 | + suspend: true # Never runs automatically |
| 12 | + jobTemplate: |
| 13 | + spec: |
| 14 | + template: |
| 15 | + spec: |
| 16 | + restartPolicy: Never |
| 17 | + volumes: |
| 18 | + - name: scripts |
| 19 | + configMap: |
| 20 | + name: etcd-rclone-scripts |
| 21 | + defaultMode: 0755 |
| 22 | + - name: snapshot |
| 23 | + emptyDir: {} |
| 24 | + - name: {{ $volume }} |
| 25 | + persistentVolumeClaim: |
| 26 | + claimName: {{ $volume }} |
| 27 | + - name: rclone-conf |
| 28 | + secret: |
| 29 | + secretName: etcd-rclone-config |
| 30 | + initContainers: |
| 31 | + - name: rclone |
| 32 | + image: docker.io/rclone/rclone |
| 33 | + command: [/bin/sh, "-c", "/scripts/rclone-download.sh"] |
| 34 | + env: |
| 35 | + - name: RCLONE_CONFIG |
| 36 | + value: /etc/rclone.conf |
| 37 | + - name: PREFIX |
| 38 | + value: {{ $.Values.backup.bucket.prefix | quote }} |
| 39 | + volumeMounts: |
| 40 | + - name: scripts |
| 41 | + mountPath: /scripts |
| 42 | + - name: snapshot |
| 43 | + mountPath: /snapshot |
| 44 | + - name: rclone-conf |
| 45 | + mountPath: /etc/rclone.conf |
| 46 | + subPath: rclone.conf |
| 47 | + - name: {{ $volume }} |
| 48 | + mountPath: /var/lib/etcd |
| 49 | + resources: |
| 50 | + requests: |
| 51 | + ephemeral-storage: "4Gi" |
| 52 | + limits: |
| 53 | + ephemeral-storage: "8Gi" |
| 54 | + containers: |
| 55 | + - name: restore-etcd |
| 56 | + image: registry.k8s.io/etcd:3.5.21-0 |
| 57 | + command: ["etcdctl"] |
| 58 | + args: |
| 59 | + - snapshot |
| 60 | + - restore |
| 61 | + - /snapshot/snapshot.db |
| 62 | + - --data-dir=/var/lib/etcd |
| 63 | + - "--name=workflows-cluster-etcd-{{ $i }}" |
| 64 | + - "--initial-cluster={{ include "workflows.etcdInitialCluster" $etcdReplicas }}" |
| 65 | + - "--initial-advertise-peer-urls=https://workflows-cluster-etcd-{{ $i }}.workflows-cluster-etcd-headless.workflows:2380" |
| 66 | + - --initial-cluster-token=workflows-cluster |
| 67 | + - --skip-hash-check=false |
| 68 | + volumeMounts: |
| 69 | + - name: {{ $volume }} |
| 70 | + mountPath: /var/lib/etcd |
| 71 | + - name: snapshot |
| 72 | + mountPath: /snapshot |
| 73 | +{{- end }} |
0 commit comments