From 2e559dacb2def5b9a08bfd931be7b3febece1965 Mon Sep 17 00:00:00 2001 From: cjc7373 Date: Fri, 10 Jan 2025 14:56:25 +0800 Subject: [PATCH] chore: support tidb 8.4 (#1384) Co-authored-by: cjc7373 (cherry picked from commit 6034185195e5eb01d375261208d6860ca5d8a756) --- README.md | 2 +- addons-cluster/tidb/templates/cluster.yaml | 4 +-- addons-cluster/tidb/values.yaml | 6 ++--- addons/tidb/dataprotection/backup.sh | 4 +-- addons/tidb/dataprotection/restore.sh | 4 +-- addons/tidb/scripts/pd_start.sh | 8 ++++++ addons/tidb/templates/actionset.yaml | 4 +-- .../tidb/templates/backuppolicytemplate.yaml | 11 ++++++++ .../templates/componentdefinition-pd.yaml | 6 +++-- .../templates/componentdefinition-tidb.yaml | 3 +++ .../templates/componentdefinition-tikv.yaml | 2 ++ addons/tidb/templates/componentversion.yaml | 25 ++++++++++++++++--- 12 files changed, 61 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d9e932510..ffc409a81 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ KubeBlocks add-ons. | risingwave | risingwave-compactor-v1.0.0
risingwave-compute-v1.0.0
risingwave-connector-v1.0.0
risingwave-frontend-v1.0.0
risingwave-meta-v1.0.0 | RisingWave is a distributed SQL streaming database that enables cost-efficient and reliable processing of streaming data. | RisingWave Labs | | starrocks-ce | starrocks-ce-be-1.0.0-alpha.0-3.2.2
starrocks-ce-be-1.0.0-alpha.0-3.3.0
starrocks-ce-fe-1.0.0-alpha.0-3.2.2
starrocks-ce-fe-1.0.0-alpha.0-3.3.0 | A Linux Foundation project, is the next-generation data platform designed to make data-intensive real-time analytics fast and easy. | yandongxiao iziang | | tdengine | tdengine-3.0.5 | TDengine is an open source, high-performance, cloud native time-series database optimized for Internet of Things (IoT), Connected Cars, Industrial IoT and DevOps. | leon-inf | -| tidb | tidb-6.5.10
tidb-7.1.5
tidb-7.5.2
tidb-pd-6.5.10
tidb-pd-7.1.5
tidb-pd-7.5.2
tikv-6.5.10
tikv-7.1.5
tikv-7.5.2 | TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. | csuzhangxc cjc7373 | +| tidb | tidb-6.5.10
tidb-7.1.5
tidb-7.5.2
tidb-8.4.0
tidb-pd-6.5.10
tidb-pd-7.1.5
tidb-pd-7.5.2
tidb-pd-8.4.0
tikv-6.5.10
tikv-7.1.5
tikv-7.5.2
tikv-8.4.0 | TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. | csuzhangxc cjc7373 | | vanilla-postgresql | anilla-postgresql-12.15.0
anilla-postgresql-14.7.0
anilla-postgresql-15.6.1-138
anilla-postgresql-15.7.0 | Vanilla-PostgreSQL is compatible with the native PostgreSQL kernel, enabling it to quickly provide HA solutions for various variants based on the native PostgreSQL kernel. | kizuna-lek | | victoria-metrics | ictoria-metrics-1.0.0 | VictoriaMetrics is a fast, cost-effective and scalable monitoring solution and time series database. | sophon-zt ButterBright | | weaviate | weaviate-1.19.6 | Weaviate is an open-source vector database. It allows you to store data objects and vector embeddings from your favorite ML-models, and scale seamlessly into billions of data objects. | iziang | diff --git a/addons-cluster/tidb/templates/cluster.yaml b/addons-cluster/tidb/templates/cluster.yaml index 42e283b84..9d57e38ba 100644 --- a/addons-cluster/tidb/templates/cluster.yaml +++ b/addons-cluster/tidb/templates/cluster.yaml @@ -1,12 +1,12 @@ apiVersion: apps.kubeblocks.io/v1 kind: Cluster metadata: - name: {{ include "clustername" . }} + name: {{ include "kblib.clusterName" . }} namespace: {{ .Release.Namespace }} labels: {{ include "tidb-cluster.labels" . | nindent 4 }} spec: clusterDef: tidb # ref clusterdefinition.name - terminationPolicy: {{ $.Values.terminationPolicy }} + terminationPolicy: {{ $.Values.extra.terminationPolicy }} topology: cluster componentSpecs: {{- with $.Values.pd }} diff --git a/addons-cluster/tidb/values.yaml b/addons-cluster/tidb/values.yaml index b0b503f40..915709367 100644 --- a/addons-cluster/tidb/values.yaml +++ b/addons-cluster/tidb/values.yaml @@ -2,10 +2,6 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -## @param terminationPolicy define Cluster termination policy. One of DoNotTerminate, Delete, WipeOut. -## -terminationPolicy: Delete - # @param appVersionOverride # if not empty, it will override the default tidb version # the version must be defined in the ComponentVersion cr. @@ -58,3 +54,5 @@ serviceAccount: extra: rbacEnabled: true + # @param terminationPolicy define Cluster termination policy. One of DoNotTerminate, Halt, Delete, WipeOut. + terminationPolicy: Delete diff --git a/addons/tidb/dataprotection/backup.sh b/addons/tidb/dataprotection/backup.sh index bc6dc9292..81bf0db82 100644 --- a/addons/tidb/dataprotection/backup.sh +++ b/addons/tidb/dataprotection/backup.sh @@ -19,13 +19,13 @@ trap handle_exit EXIT function getToolConfigValue() { local var=$1 - cat $toolConfig | grep "$var" | awk '{print $NF}' + cat $toolConfig | grep "^$var" | awk '{print $NF}' } access_key_id=$(getToolConfigValue access_key_id) secret_access_key=$(getToolConfigValue secret_access_key) endpoint=$(getToolConfigValue endpoint) -bucket=$(getToolConfigValue root) +bucket=$(getToolConfigValue "root") # FIXME: hardcoded port /br backup full --pd "$DP_DB_HOST:2379" --storage "s3://$bucket$DP_BACKUP_BASE_PATH?access-key=$access_key_id&secret-access-key=$secret_access_key" --s3.endpoint "$endpoint" diff --git a/addons/tidb/dataprotection/restore.sh b/addons/tidb/dataprotection/restore.sh index 91e711dfe..95e57ad05 100644 --- a/addons/tidb/dataprotection/restore.sh +++ b/addons/tidb/dataprotection/restore.sh @@ -7,13 +7,13 @@ toolConfig=/etc/datasafed/datasafed.conf function getToolConfigValue() { local var=$1 - cat $toolConfig | grep "$var" | awk '{print $NF}' + cat $toolConfig | grep "^$var" | awk '{print $NF}' } access_key_id=$(getToolConfigValue access_key_id) secret_access_key=$(getToolConfigValue secret_access_key) endpoint=$(getToolConfigValue endpoint) -bucket=$(getToolConfigValue root) +bucket=$(getToolConfigValue "root") # FIXME: hardcoded port /br restore full --pd "$DP_DB_HOST:2379" --storage "s3://$bucket$DP_BACKUP_BASE_PATH?access-key=$access_key_id&secret-access-key=$secret_access_key" --s3.endpoint "$endpoint" diff --git a/addons/tidb/scripts/pd_start.sh b/addons/tidb/scripts/pd_start.sh index 88bc03704..309ad15ed 100644 --- a/addons/tidb/scripts/pd_start.sh +++ b/addons/tidb/scripts/pd_start.sh @@ -49,6 +49,14 @@ set_join_args() { } get_current_pod_fqdn() { + if [[ -z $CURRENT_POD_NAME ]]; then + echo "CURRENT_POD_NAME not set" + exit 1 + fi + if [[ -z $PD_POD_FQDN_LIST ]]; then + echo "PD_POD_FQDN_LIST not set" + exit 1 + fi replicas=$(echo "${PD_POD_FQDN_LIST}" | tr ',' '\n') echo "$replicas" | grep "$CURRENT_POD_NAME" } diff --git a/addons/tidb/templates/actionset.yaml b/addons/tidb/templates/actionset.yaml index 8c9cf5911..ed00d008d 100644 --- a/addons/tidb/templates/actionset.yaml +++ b/addons/tidb/templates/actionset.yaml @@ -8,7 +8,7 @@ spec: backupType: Full backup: backupData: - image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.br.repository }}:{{ default .Chart.AppVersion .Values.image.tag }} + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.br.repository }}:$(IMAGE_TAG) syncProgress: enabled: false intervalSeconds: 5 @@ -20,7 +20,7 @@ spec: restore: postReady: - job: - image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.br.repository }}:{{ default .Chart.AppVersion .Values.image.tag }} + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.br.repository }}:$(IMAGE_TAG) command: - bash - -c diff --git a/addons/tidb/templates/backuppolicytemplate.yaml b/addons/tidb/templates/backuppolicytemplate.yaml index 80c034c4f..ab54b0dc8 100644 --- a/addons/tidb/templates/backuppolicytemplate.yaml +++ b/addons/tidb/templates/backuppolicytemplate.yaml @@ -12,3 +12,14 @@ spec: - name: br snapshotVolumes: false actionSetName: tidb-br + env: + - name: IMAGE_TAG + valueFrom: + versionMapping: + - serviceVersions: + - "6" + - "7" + mappedValue: "v7.5.2" + - serviceVersions: + - "8" + mappedValue: "v8.4.0" diff --git a/addons/tidb/templates/componentdefinition-pd.yaml b/addons/tidb/templates/componentdefinition-pd.yaml index 144202b66..cdcf11fd4 100644 --- a/addons/tidb/templates/componentdefinition-pd.yaml +++ b/addons/tidb/templates/componentdefinition-pd.yaml @@ -33,6 +33,8 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.name + - name: SERVICE_PORT + value: "2379" ports: - containerPort: 2379 name: client @@ -78,9 +80,9 @@ spec: - | LEADER_NAME=$(/pd-ctl member | jq -r '.leader.name') if [ "$LEADER_NAME" == "$HOSTNAME" ]; then - echo "leader" + echo -n "leader" else - echo "follower" + echo -n "follower" fi memberLeave: exec: diff --git a/addons/tidb/templates/componentdefinition-tidb.yaml b/addons/tidb/templates/componentdefinition-tidb.yaml index c749f8b87..603648b00 100644 --- a/addons/tidb/templates/componentdefinition-tidb.yaml +++ b/addons/tidb/templates/componentdefinition-tidb.yaml @@ -46,6 +46,8 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.name + - name: SERVICE_PORT + value: "10080" ports: - containerPort: 4000 name: client @@ -61,6 +63,7 @@ spec: --host=0.0.0.0 \ --path=${PD_ADDRESS} \ --log-slow-query=/var/log/tidb/slowlog \ + --log-file=/var/log/tidb/running.log \ --config=/etc/tidb/tidb.toml volumeMounts: - name: slowlog diff --git a/addons/tidb/templates/componentdefinition-tikv.yaml b/addons/tidb/templates/componentdefinition-tikv.yaml index 65b64025e..c97cc3b2c 100644 --- a/addons/tidb/templates/componentdefinition-tikv.yaml +++ b/addons/tidb/templates/componentdefinition-tikv.yaml @@ -45,6 +45,8 @@ spec: fieldRef: apiVersion: v1 fieldPath: metadata.name + - name: SERVICE_PORT + value: "20180" ports: - containerPort: 20160 name: peer diff --git a/addons/tidb/templates/componentversion.yaml b/addons/tidb/templates/componentversion.yaml index 3d2d5531f..38c68e531 100644 --- a/addons/tidb/templates/componentversion.yaml +++ b/addons/tidb/templates/componentversion.yaml @@ -8,6 +8,12 @@ metadata: {{- include "tidb.apiVersion" . | nindent 4 }} spec: releases: + - name: "8.4.0" + serviceVersion: "8.4.0" + images: + pd: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.pd.repository }}:v8.4.0 + roleProbe: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.pd.repository }}:v8.4.0 + memberLeave: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.pd.repository }}:v8.4.0 - name: "7.5.2" serviceVersion: "7.5.2" images: @@ -30,8 +36,9 @@ spec: - compDefs: - {{ include "tidb.pd7.cmpdRegexpPattern" . }} releases: - - "7.1.5" + - "8.4.0" - "7.5.2" + - "7.1.5" - "6.5.10" --- @@ -45,6 +52,11 @@ metadata: {{- include "tidb.apiVersion" . | nindent 4 }} spec: releases: + - name: "8.4.0" + serviceVersion: "8.4.0" + images: + tidb: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tidb.repository }}:v8.4.0 + slowlog: {{ .Values.image.helper.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.image.helper.repository }}:{{ .Values.image.helper.tag }} - name: "7.5.2" serviceVersion: "7.5.2" images: @@ -64,8 +76,9 @@ spec: - compDefs: - {{ include "tidb.tidb7.cmpdRegexpPattern" . }} releases: - - "7.1.5" + - "8.4.0" - "7.5.2" + - "7.1.5" - "6.5.10" --- @@ -79,6 +92,11 @@ metadata: {{- include "tidb.apiVersion" . | nindent 4 }} spec: releases: + - name: "8.4.0" + serviceVersion: "8.4.0" + images: + tikv: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tikv.repository }}:v8.4.0 + memberLeave: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.pd.repository }}:v8.4.0 - name: "7.5.2" serviceVersion: "7.5.2" images: @@ -98,6 +116,7 @@ spec: - compDefs: - {{ include "tidb.tikv7.cmpdRegexpPattern" . }} releases: - - "7.1.5" + - "8.4.0" - "7.5.2" + - "7.1.5" - "6.5.10"