Upgrade TiDB Operator
This document describes how to upgrade TiDB Operator to a specific version. You can choose either online upgrade or offline upgrade.
Online upgrade
If your server has access to the internet, you can perform online upgrade by taking the following steps:
Before upgrading TiDB Operator, make sure that the Helm repo contains the TiDB Operator version you want to upgrade to. To check the TiDB Operator versions in the Helm repo, run the following command:
helm search repo -l tidb-operatorIf the command output does not include the version you need, update the repo using the
helm repo update
command. For details, refer to Configure the Help repo.Update CustomResourceDefinition (CRD) for Kubernetes:
kubectl apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.2.7/manifests/crd.yaml && \ kubectl get crd tidbclusters.pingcap.comGet the
values.yaml
file of thetidb-operator
chart:mkdir -p ${HOME}/tidb-operator/v1.2.7 && \ helm inspect values pingcap/tidb-operator --version=v1.2.7 > ${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yamlIn the
${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yaml
file, modify theoperatorImage
version to the new TiDB Operator version.If you have added customized configuration in the old
values.yaml
file, merge your customized configuration to the${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yaml
file.Perform upgrade:
helm upgrade tidb-operator pingcap/tidb-operator --version=v1.2.7 -f ${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yaml -n tidb-adminAfter all the Pods start normally, check the image of TiDB Operator:
kubectl get po -n tidb-admin -l app.kubernetes.io/instance=tidb-operator -o yaml | grep 'image:.*operator:'If you see a similar output as follows, TiDB Operator is successfully upgraded.
v1.2.7
represents the TiDB Operator version you have upgraded to.image: pingcap/tidb-operator:v1.2.7 image: docker.io/pingcap/tidb-operator:v1.2.7 image: pingcap/tidb-operator:v1.2.7 image: docker.io/pingcap/tidb-operator:v1.2.7
Offline upgrade
If your server cannot access the Internet, you can offline upgrade by taking the following steps:
Download the files and images required for the upgrade using a machine with Internet access:
Download the
crd.yaml
file for the new TiDB Operator version. For more information about CRD, see CustomResourceDefinition.wget https://raw.githubusercontent.com/pingcap/tidb-operator/v1.2.7/manifests/crd.yamlDownload the
tidb-operator
chart package file.wget http://charts.pingcap.org/tidb-operator-v1.2.7.tgzDownload the Docker images required for the new TiDB Operator version:
docker pull pingcap/tidb-operator:v1.2.7 docker pull pingcap/tidb-backup-manager:v1.2.7 docker save -o tidb-operator-v1.2.7.tar pingcap/tidb-operator:v1.2.7 docker save -o tidb-backup-manager-v1.2.7.tar pingcap/tidb-backup-manager:v1.2.7
Upload the downloaded files and images to the server where TiDB Operator is deployed, and install the new TiDB Operator version:
Install the
crd.yaml
file for TiDB Operator:kubectl replace -f ./crd.yamlUnpack the
tidb-operator
chart package file, and copy thevalues.yaml
file to the directory of the new TiDB Operator:tar zxvf tidb-operator-v1.2.7.tgz && \ mkdir -p ${HOME}/tidb-operator/v1.2.7 && \ cp tidb-operator/values.yaml ${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yamlInstall the Docker images on the server:
docker load -i tidb-operator-v1.2.7.tar && \ docker load -i tidb-backup-manager-v1.2.7.tar
In the
${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yaml
file, modify theoperatorImage
version to the new TiDB Operator version.If you have added customized configuration in the old
values.yaml
file, merge your customized configuration to the${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yaml
file.Perform upgrade:
helm upgrade tidb-operator ./tidb-operator --version=v1.2.7 -f ${HOME}/tidb-operator/v1.2.7/values-tidb-operator.yamlAfter all the Pods start normally, check the image version of TiDB Operator:
kubectl get po -n tidb-admin -l app.kubernetes.io/instance=tidb-operator -o yaml | grep 'image:.*operator:'If you see a similar output as follows, TiDB Operator is successfully upgraded.
v1.2.7
represents the TiDB Operator version you have upgraded to.image: pingcap/tidb-operator:v1.2.7 image: docker.io/pingcap/tidb-operator:v1.2.7 image: pingcap/tidb-operator:v1.2.7 image: docker.io/pingcap/tidb-operator:v1.2.7