-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
restore database from cloud #160
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ab2f1c2
TiDB readiness probes (#147)
weekface 1969b98
Merge branch 'master' into restore_base_backup
xiaojingchen 453713c
Merge branch 'master' into restore_base_backup
xiaojingchen 0928a45
typo
xiaojingchen a7e612d
fix script
xiaojingchen ec1c0b3
address comment
xiaojingchen 2de846a
address comment
xiaojingchen 1398465
Merge branch 'master' into restore_base_backup
xiaojingchen d9d003b
address comment
xiaojingchen 1b6864a
Merge branch 'master' into restore_base_backup
tennix b0d0450
address comment
xiaojingchen 4874028
Merge branch 'master' into restore_base_backup
xiaojingchen 01140c1
Merge branch 'restore_base_backup' of https://github.com/xiaojingchen…
xiaojingchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{- if .Values.restore.create }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ .Values.clusterName }}-restore | ||
labels: | ||
app.kubernetes.io/name: {{ template "chart.name" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/instance: {{ .Values.clusterName }} | ||
app.kubernetes.io/component: restore | ||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ template "chart.name" . }} | ||
app.kubernetes.io/instance: {{ .Values.clusterName }} | ||
app.kubernetes.io/component: restore | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: tidb-restore-job | ||
image: {{ .Values.restore.image }} | ||
command: | ||
- /bin/sh | ||
- -c | ||
- |- | ||
{{ tuple "scripts/_start_restore.sh.tpl" . | include "helm-toolkit.utils.template" | indent 10 }} | ||
volumeMounts: | ||
- name: data | ||
mountPath: "/data" | ||
{{- if .Values.restore.gcp }} | ||
- name: gcp-credentials | ||
mountPath: "/gcp" | ||
readOnly: true | ||
{{- end }} | ||
env: | ||
- name: MY_POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
{{- if .Values.restore.gcp }} | ||
- name: GOOGLE_APPLICATION_CREDENTIALS | ||
value: /gcp/credentials.json | ||
{{- end }} | ||
- name: TIDB_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.clusterName }}-restore-secret | ||
key: user-password | ||
restartPolicy: OnFailure | ||
volumes: | ||
- name: data | ||
persistentVolumeClaim: | ||
claimName: {{ .Values.clusterName }}-restore | ||
{{- if .Values.restore.gcp }} | ||
- name: gcp-credentials | ||
secret: | ||
secretName: {{ .Values.clusterName }}-restore-secret | ||
{{- end }} | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{- if .Values.restore.create }} | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: {{ .Values.clusterName }}-restore | ||
labels: | ||
app.kubernetes.io/name: {{ template "chart.name" . }} | ||
app.kubernetes.io/managed-by: tidb-operator | ||
app.kubernetes.io/instance: {{ .Values.clusterName }} | ||
app.kubernetes.io/component: restore | ||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: {{ .Values.restore.storage }} | ||
storageClassName: {{ .Values.restore.storageClassName }} | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{- if .Values.restore.create }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ .Values.clusterName }}-restore | ||
labels: | ||
app.kubernetes.io/name: {{ template "chart.name" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/instance: {{ .Values.clusterName }} | ||
app.kubernetes.io/component: restore | ||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} | ||
type: Opaque | ||
data: | ||
{{- if .Values.restore.gcp }} | ||
credentials.json: {{ .Values.restore.gcp.credentialsData }} | ||
{{- end }} | ||
user-password: {{ .Values.restore.password | b64enc | quote }} | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
charts/tidb-cluster/templates/scripts/_start_restore.sh.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
set -euo pipefail | ||
|
||
dirname=`date +%Y-%m-%dT%H%M%S`-${MY_POD_NAME} | ||
dataDir=/data/${dirname} | ||
mkdir -p ${dataDir}/ | ||
host=`echo {{ .Values.clusterName }}_TIDB_SERVICE_HOST | tr '[a-z]' '[A-Z]'` | ||
|
||
{{- if .Values.restore.gcp }} | ||
downloader \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The latest image is just pushed to DockerHub. |
||
--cloud=gcp \ | ||
--bucket={{ .Values.restore.gcp.bucket }} \ | ||
--srcDir={{ .Values.restore.gcp.srcDir }} \ | ||
--destDir=${dataDir} | ||
|
||
/loader \ | ||
-d ${dataDir}/{{ .Values.restore.gcp.srcDir }} \ | ||
-h `eval echo '${'$host'}'` \ | ||
-u {{ .Values.restore.user }} \ | ||
-p ${TIDB_PASSWORD} \ | ||
-P 4000 \ | ||
{{ .Values.restore.options }} | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is here a second time.