当前位置:网站首页>Upgrade tidb operator

Upgrade tidb operator

2022-07-06 08:02:00 Tianxiang shop

This article describes how to upgrade TiDB Operator To the specified version . You can choose Online upgrade or Offline upgrade .

Upgrade considerations

  1. If you use v1.3.0-beta.1 And earlier versions of TiDB Operator Span Kubernetes Cluster deployment TiDB colony , Upgrade directly TiDB Operator It will cause the cluster to roll update and enter an abnormal state . If upgrading from an earlier version TiDB Operator To v1.3, You need to do the following :

    1. to update CRD.
    2. modify TidbCluster The definition will  spec.acrossK8s  Field set to  true.
    3. upgrade TiDB Operator.
  2. Abandoning Pod ValidatingWebhook  and  MutatingWebhook. If you use v1.2 And earlier versions of TiDB Operator Deployed in the cluster Webhook, And enabled Pod ValidatingWebhook  and  MutatingWebhook, upgrade TiDB Operator To v1.3.0-beta.1 And later ,Pod ValidatingWebhook  and  MutatingWebhook  Be deleted , But it won't be right TiDB Cluster management has an impact , It will not affect the running TiDB colony .

Online upgrade

If the server can access the Internet , You can follow these steps to upgrade online TiDB Operator:

  1. upgrade TiDB Operator front , Make sure Helm repo Include what you need to upgrade TiDB Operator edition . Check... With the following command Helm repo Contains TiDB Operator edition :

    helm search repo -l tidb-operator

    If the output does not contain the new version you need , have access to  helm repo update  The command to update repo. Please refer to To configure Helm repo.

  2. to update Kubernetes Of CustomResourceDefinition (CRD). About CRD For more information , see also  CustomResourceDefinition.

    • If Kubernetes Version greater than or equal to 1.16:

      1. If TiDB Operator from v1.2.x And earlier versions to v1.3.x And later versions , You need to execute the following command to create the newly added TidbNGMonitoring CRD. If it is v1.3.x And later versions TiDB Operator upgrade , But skip this step .

        kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/${operator_version}/manifests/crd/v1/pingcap.com_tidbngmonitorings.yaml

      2. to update CRD.

        kubectl replace -f https://raw.githubusercontent.com/pingcap/tidb-operator/${operator_version}/manifests/crd.yaml && \ kubectl get crd tidbclusters.pingcap.com

    • If Kubernetes Version less than 1.16:

      1. If TiDB Operator from v1.2.x And earlier versions to v1.3.x And later versions , You need to execute the following command to create the newly added TidbNGMonitoring CRD. If it is v1.3.x And later versions TiDB Operator upgrade , But skip this step .

        kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/${operator_version}/manifests/crd/v1beta1/pingcap.com_tidbngmonitorings.yaml

      2. to update CRD.

        kubectl replace -f https://raw.githubusercontent.com/pingcap/tidb-operator/${operator_version}/manifests/crd_v1beta1.yaml && \ kubectl get crd tidbclusters.pingcap.com

    This article takes TiDB Operator v1.3.5 For example , You need to replace  ${operator_version}  For the one you want to upgrade to TiDB Operator edition .

  3. Get what you want to upgrade  tidb-operator chart Medium  values.yaml  file :

    mkdir -p ${HOME}/tidb-operator/v1.3.5 && \ helm inspect values pingcap/tidb-operator --version=v1.3.5 > ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml

  4. modify  ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml  in  operatorImage  The image version is the version to be upgraded .

  5. If you are in the old version  values.yaml  Custom configuration is set in , Merge custom configurations into  ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml  in .

  6. Perform upgrade :

    helm upgrade tidb-operator pingcap/tidb-operator --version=v1.3.5 -f ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml

  7. Pod After all normal starts , Run the following command to confirm TiDB Operator Mirror version :

    kubectl get po -n tidb-admin -l app.kubernetes.io/instance=tidb-operator -o yaml | grep 'image:.*operator:'

    If the output is similar to the result below , It means that the upgrade is successful . among ,v1.3.5  Indicates the version number upgraded to .

    image: pingcap/tidb-operator:v1.3.5 image: docker.io/pingcap/tidb-operator:v1.3.5 image: pingcap/tidb-operator:v1.3.5 image: docker.io/pingcap/tidb-operator:v1.3.5

    Be careful

    TiDB Operator After the upgrade , all TiDB In the cluster  discovery Deployment Will be automatically upgraded to the corresponding TiDB Operator edition .

Offline upgrade

If the server is not connected to the Internet , You can follow the following steps to upgrade offline TiDB Operator:

  1. Use a machine with an Internet , Download the files and images required for the upgrade .

    1. download TiDB Operator Needed  crd.yaml  file . About CRD For more information , see also  CustomResourceDefinition.

      • If Kubernetes Version greater than or equal to 1.16:

        wget -O crd.yaml https://raw.githubusercontent.com/pingcap/tidb-operator/${operator_version}/manifests/crd.yaml

      • If Kubernetes Version less than 1.16:

        wget -O crd.yaml https://raw.githubusercontent.com/pingcap/tidb-operator/${operator_version}/manifests/crd_v1beta1.yaml

      This article takes TiDB Operator v1.3.5 For example , You need to replace  ${operator_version}  For the one you want to upgrade to TiDB Operator edition .

    2. download  tidb-operator chart Package file :

      wget http://charts.pingcap.org/tidb-operator-v1.3.5.tgz

    3. download TiDB Operator Upgrade required Docker Mirror image :

      docker pull pingcap/tidb-operator:v1.3.5 docker pull pingcap/tidb-backup-manager:v1.3.5 docker save -o tidb-operator-v1.3.5.tar pingcap/tidb-operator:v1.3.5 docker save -o tidb-backup-manager-v1.3.5.tar pingcap/tidb-backup-manager:v1.3.5

  2. Upload the downloaded files and images to the server that needs to be upgraded , Follow the steps below to install on the server :

    1. If TiDB Operator from v1.2.x And earlier versions to v1.3.x And later versions , You need to execute the following command to create the newly added TidbNGMonitoring CRD. If it is v1.3.x And later versions TiDB Operator upgrade , But skip this step .

      kubectl create -f ./crd.yaml

      For others CRD, When executing this command, it will report "AlreadyExists" Error of , You can ignore this error .

    2. upgrade TiDB Operator Needed  crd.yaml  file :

      kubectl replace -f ./crd.yaml

    3. decompression  tidb-operator chart Package file , And copy  values.yaml  File to upgrade directory :

      tar zxvf tidb-operator-v1.3.5.tgz && \ mkdir -p ${HOME}/tidb-operator/v1.3.5 && \ cp tidb-operator/values.yaml ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml

    4. install Docker Mirror to server :

      docker load -i tidb-operator-v1.3.5.tar && \ docker load -i tidb-backup-manager-v1.3.5.tar

  3. modify  ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml  in  operatorImage  The image version is the version to be upgraded .

  4. If you are in the old version  values.yaml  Custom configuration is set in , Merge custom configurations into  ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml  in .

  5. Perform upgrade :

    helm upgrade tidb-operator ./tidb-operator --version=v1.3.5 -f ${HOME}/tidb-operator/v1.3.5/values-tidb-operator.yaml

  6. Pod After all normal starts , Run the following command to confirm TiDB Operator Mirror version :

    kubectl get po -n tidb-admin -l app.kubernetes.io/instance=tidb-operator -o yaml | grep 'image:.*operator:'

    If the output is similar to the result below , It means that the upgrade is successful . among ,v1.3.5  Indicates the version number upgraded to .

    image: pingcap/tidb-operator:v1.3.5 image: docker.io/pingcap/tidb-operator:v1.3.5 image: pingcap/tidb-operator:v1.3.5 image: docker.io/pingcap/tidb-operator:v1.3.5

    Be careful

    TiDB Operator After the upgrade , all TiDB In the cluster  discovery Deployment Will be automatically upgraded to the corresponding TiDB Operator edition .

原网站

版权声明
本文为[Tianxiang shop]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060758157177.html