From b4cda098a486283bc9cdc393e4d9a89f98bcaa55 Mon Sep 17 00:00:00 2001 From: Yunchi Luo Date: Mon, 17 Feb 2020 02:50:53 -0500 Subject: [PATCH] tidb-backup: add restoreUsingExistingVolume option (#1708) --- charts/tidb-backup/templates/backup-pvc.yaml | 6 +++++- charts/tidb-backup/templates/restore-job.yaml | 4 +++- charts/tidb-backup/values.yaml | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/charts/tidb-backup/templates/backup-pvc.yaml b/charts/tidb-backup/templates/backup-pvc.yaml index 290868f8af..5f1bfbc051 100644 --- a/charts/tidb-backup/templates/backup-pvc.yaml +++ b/charts/tidb-backup/templates/backup-pvc.yaml @@ -1,8 +1,12 @@ -{{- if (or (eq .Values.mode "backup") (eq .Values.mode "scheduled-restore")) }} +{{- if (or (eq .Values.mode "backup") (eq .Values.mode "scheduled-restore") (and (eq .Values.mode "restore") (not .Values.restoreUsingExistingVolume))) }} kind: PersistentVolumeClaim apiVersion: v1 metadata: + {{- if eq .Values.mode "restore" }} + name: restore-{{ tpl .Values.name . }} + {{- else }} name: {{ tpl .Values.name . }} + {{- end }} labels: app.kubernetes.io/name: {{ template "chart.name" . }} app.kubernetes.io/managed-by: tidb-operator diff --git a/charts/tidb-backup/templates/restore-job.yaml b/charts/tidb-backup/templates/restore-job.yaml index d5cd17a6ab..3ce3f79509 100644 --- a/charts/tidb-backup/templates/restore-job.yaml +++ b/charts/tidb-backup/templates/restore-job.yaml @@ -77,7 +77,9 @@ spec: volumes: - name: data persistentVolumeClaim: - {{- if .Values.scheduledBackupName }} + {{- if not .Values.restoreUsingExistingVolume }} + claimName: restore-{{ .Values.name }} + {{- else if .Values.scheduledBackupName }} claimName: {{ .Values.name }}-scheduled-backup {{- else }} claimName: {{ .Values.name }} diff --git a/charts/tidb-backup/values.yaml b/charts/tidb-backup/values.yaml index 1d6085d166..3768cc4890 100644 --- a/charts/tidb-backup/values.yaml +++ b/charts/tidb-backup/values.yaml @@ -80,6 +80,11 @@ restoreOptions: "-t 16" # When a GC happens, the current time minus this value is the safe point. tikvGCLifeTime: 720h +# By default, restores are performed by binding to an existing volume containing backup data. +# To restore from gcp, ceph, or s3, set this to false to create a new volume to load the backup into +# This setting only affects the "restore" mode. +restoreUsingExistingVolume: true + # By default, the backup/restore uses PV to store/load backup data # You can choose to store/load backup data to/from gcp, ceph or s3 bucket by enabling the following corresponding section: