From e34a4e4a6eaeb0912f1282d19c17cc048bc29bfb Mon Sep 17 00:00:00 2001 From: cjc7373 Date: Tue, 10 Sep 2024 14:51:12 +0800 Subject: [PATCH] chore: support tidb 6.5 (#910) --- addons-cluster/tidb/values.yaml | 3 +++ addons/tidb/scripts/pd_start.sh | 6 ++++++ .../templates/componentdefinition-tidb.yaml | 17 ++++++++++++++-- addons/tidb/templates/componentversion.yaml | 20 +++++++++++++++++-- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/addons-cluster/tidb/values.yaml b/addons-cluster/tidb/values.yaml index 128f11437..c8dd7d5f2 100644 --- a/addons-cluster/tidb/values.yaml +++ b/addons-cluster/tidb/values.yaml @@ -66,3 +66,6 @@ tidb: # The RBAC permission used by cluster component pod, now include event.create serviceAccount: name: "" + +extra: + rbacEnabled: true diff --git a/addons/tidb/scripts/pd_start.sh b/addons/tidb/scripts/pd_start.sh index c0e173199..57715213b 100644 --- a/addons/tidb/scripts/pd_start.sh +++ b/addons/tidb/scripts/pd_start.sh @@ -29,6 +29,12 @@ if [[ -f $DATA_DIR/join ]]; then elif [[ ! -d $DATA_DIR/member/wal ]]; then echo "first started pod" replicas=$(echo "${KB_POD_LIST}" | tr ',' '\n') + # FIXME: Relying on leader status to determine whether to join or initialize a cluster + # is unreliable. Consider a scenario with 3 pods: 2 start normally, while the 3rd pod + # pulls image slowly and is still initializing. During this time, the PD cluster + # achieves quorum and begins to work, thus KB's role probe succeeds. + # When the third pod eventually starts, it mistakenly attempts to join the + # cluster based on the KB_LEADER env, leading to a failure. if [[ -n $KB_LEADER || -n $KB_FOLLOWERS ]]; then echo "joining an existing cluster" join="" diff --git a/addons/tidb/templates/componentdefinition-tidb.yaml b/addons/tidb/templates/componentdefinition-tidb.yaml index 9104af9e4..c7456e2ad 100644 --- a/addons/tidb/templates/componentdefinition-tidb.yaml +++ b/addons/tidb/templates/componentdefinition-tidb.yaml @@ -9,6 +9,20 @@ spec: description: tidb's SQL layer serviceKind: MySQL updateStrategy: BestEffortParallel + vars: + - name: PD_HOST + valueFrom: + serviceVarRef: + compDef: tidb-pd-7 + host: Required + - name: PD_PORT + valueFrom: + serviceVarRef: + compDef: tidb-pd-7 + port: + name: client + - name: PD_ADDRESS + value: "$(PD_HOST).$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:$(PD_PORT)" runtime: containers: - name: tidb @@ -23,11 +37,10 @@ spec: - -c - | echo "start tidb..." - DOMAIN=$KB_NAMESPACE".svc{{ .Values.clusterDomain }}" exec /tidb-server --store=tikv \ --advertise-address=${KB_POD_FQDN}{{ .Values.clusterDomain }} \ --host=0.0.0.0 \ - --path=${KB_CLUSTER_NAME}-tidb-pd.${DOMAIN}:2379 \ + --path=${PD_ADDRESS} \ --log-slow-query=/var/log/tidb/slowlog \ --config=/etc/tidb/tidb.toml volumeMounts: diff --git a/addons/tidb/templates/componentversion.yaml b/addons/tidb/templates/componentversion.yaml index d6e231f93..3c652ec76 100644 --- a/addons/tidb/templates/componentversion.yaml +++ b/addons/tidb/templates/componentversion.yaml @@ -14,12 +14,17 @@ spec: serviceVersion: "7.1.5" images: pd: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.pd.repository }}:v7.1.5 + - name: "6.5.10" + serviceVersion: "6.5.10" + images: + pd: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.pd.repository }}:v6.5.10 compatibilityRules: - compDefs: - "tidb-pd-7" releases: - "7.1.5" - "7.5.2" + - "6.5.10" --- apiVersion: apps.kubeblocks.io/v1alpha1 @@ -34,18 +39,24 @@ spec: serviceVersion: "7.5.2" images: tidb: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tidb.repository }}:v7.5.2 - slowlog: {{ .Values.image.helper.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.image.helper.repository }}/{{ .Values.image.helper.tag }} + slowlog: {{ .Values.image.helper.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.image.helper.repository }}:{{ .Values.image.helper.tag }} - name: "7.1.5" serviceVersion: "7.1.5" images: tidb: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tidb.repository }}:v7.1.5 - slowlog: {{ .Values.image.helper.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.image.helper.repository }}/{{ .Values.image.helper.tag }} + slowlog: {{ .Values.image.helper.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.image.helper.repository }}:{{ .Values.image.helper.tag }} + - name: "6.5.10" + serviceVersion: "6.5.10" + images: + tidb: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tidb.repository }}:v6.5.10 + slowlog: {{ .Values.image.helper.registry | default ( .Values.image.registry | default "docker.io" ) }}/{{ .Values.image.helper.repository }}:{{ .Values.image.helper.tag }} compatibilityRules: - compDefs: - "tidb-7" releases: - "7.1.5" - "7.5.2" + - "6.5.10" --- apiVersion: apps.kubeblocks.io/v1alpha1 @@ -64,9 +75,14 @@ spec: serviceVersion: "7.1.5" images: tikv: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tikv.repository }}:v7.1.5 + - name: "6.5.10" + serviceVersion: "6.5.10" + images: + tikv: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tikv.repository }}:v6.5.10 compatibilityRules: - compDefs: - "tikv-7" releases: - "7.1.5" - "7.5.2" + - "6.5.10"