-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TiDB readiness probes (#147) * add readiness probes for tidb service * fix script
- Loading branch information
1 parent
46ca644
commit 744fd54
Showing
6 changed files
with
150 additions
and
1 deletion.
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,61 @@ | ||
{{- 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 | ||
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 \ | ||
--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