Perform a Canary Upgrade on TiDB Operator
This document describes how to perform a canary upgrade on TiDB Operator. Using canary upgrades, you can prevent normal TiDB Operator upgrade from causing an unexpected impact on all the TiDB clusters in Kubernetes. After you confirm the impact of TiDB Operator upgrade or that the upgraded TiDB Operator works stably, you can normally upgrade TiDB Operator.
Related parameters
To support canary upgrade, some parameters are added to the values.yaml
file in the tidb-operator
chart. See Related parameters for details.
Canary upgrade process
Configure selector for the current TiDB Operator:
Refer to Upgrade TiDB Operator. Add the following configuration in the
values.yaml
file, and upgrade TiDB Operator:controllerManager: selector: - version!=canaryIf you have already performed the step above, skip to Step 2.
Deploy the canary TiDB Operator:
Refer to Deploy TiDB Operator. Add the following configuration in the
values.yaml
file, and deploy the canary TiDB Operator in a different namespace (such astidb-admin-canary
) with a different Helm Release Name (such ashelm install tidb-operator-canary ...
):controllerManager: selector: - version=canary appendReleaseSuffix: true #scheduler: # create: false advancedStatefulset: create: false admissionWebhook: create: falseTo test the canary upgrade of
tidb-controller-manager
, set labels for a TiDB cluster by running the following command:kubectl -n ${namespace} label tc ${cluster_name} version=canaryCheck the logs of the two deployed
tidb-controller-manager
s, and you can see this TiDB cluster is now managed by the canary TiDB Operator:View the log of
tidb-controller-manager
of the current TiDB Operator:kubectl -n tidb-admin logs tidb-controller-manager-55b887bdc9-lzdwvI0305 07:52:04.558973 1 tidb_cluster_controller.go:148] TidbCluster has been deleted tidb-cluster-1/basic1View the log of
tidb-controller-manager
of the canary TiDB Operator:kubectl -n tidb-admin-canary logs tidb-controller-manager-canary-6dcb9bdd95-qf4qrI0113 03:38:43.859387 1 tidbcluster_control.go:69] TidbCluster: [tidb-cluster-1/basic1] updated successfully
To test the canary upgrade of
tidb-scheduler
, modifyspec.schedulerName
of some TiDB cluster totidb-scheduler-canary
by running the following command:kubectl -n ${namespace} edit tc ${cluster_name}After the modification, all components in the cluster will be rolling updated.
Check the logs of
tidb-scheduler
of the canary TiDB Operator, and you can see this TiDB cluster is now using the canarytidb-scheduler
:kubectl -n tidb-admin-canary logs tidb-scheduler-canary-7f7b6c7c6-j5p2j -c tidb-schedulerAfter the tests, you can revert the changes in Step 3 and Step 4 so that the TiDB cluster is again managed by the current TiDB Operator.
kubectl -n ${namespace} label tc ${cluster_name} version-kubectl -n ${namespace} edit tc ${cluster_name}Delete the canary TiDB Operator:
helm -n tidb-admin-canary uninstall ${release_name}Refer to Upgrade TiDB Operator and upgrade the current TiDB Operator normally.