Skip to content

Commit

Permalink
tidb-in-kubernetes: add doc to restart tidb components on k8s (#1759) (
Browse files Browse the repository at this point in the history
…#1938)

* tidb-in-kubernetes: add doc to restart tidb components on k8s

* address comments

* tidb-in-kubernetes: refine format

* make the same changes as before

* address comments from lilian

* address comment on wording

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com>

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com>
  • Loading branch information
5 people authored Mar 4, 2020
1 parent 482ad5b commit a3eb80e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@
- [Collect Logs](/tidb-in-kubernetes/maintain/log-collecting.md)
- [Automatic Failover](/tidb-in-kubernetes/maintain/auto-failover.md)
- [TiDB Binlog](/tidb-in-kubernetes/maintain/tidb-binlog.md)
- [Restart a TiDB Cluster](/tidb-in-kubernetes/maintain/restart.md)
- [Scale](/tidb-in-kubernetes/scale-in-kubernetes.md)
+ Upgrade
- [TiDB Cluster](/tidb-in-kubernetes/upgrade/tidb-cluster.md)
Expand Down
72 changes: 72 additions & 0 deletions tidb-in-kubernetes/maintain/restart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Restart a TiDB Cluster in Kubernetes
summary: Learn how to restart a TiDB cluster in the Kubernetes cluster.
category: how-to
---

# Restart a TiDB Cluster in Kubernetes

This document describes how to forcibly restart a TiDB cluster in the Kubernetes cluster, including restarting a Pod, restarting all Pods of a component, and restarting all Pods of the TiDB cluster.

> **Note:**
>
> TiDB Operator v1.0.x only supports restarting the Pod in a forcible way.
>
> - If the PD Pod being restarted is the PD leader, its leadership does not automatically transfer, which can cause the PD service to be temporarily unavailable.
> - If the TiKV Pod being restarted contains a Region leader of the TiKV cluster, its leadership does not automatically transfer, which can cause the requests of accessing the corresponding data to fail.
> - Restarting the TiDB Pod can cause the requests of accessing this Pod to fail.
## Forcibly restart a Pod

Execute the following command to forcibly restart a Pod:

{{< copyable "shell-regular" >}}

```shell
kubectl delete pod -n <namespace> <pod-name>
```

## Forcibly restart all Pods of a component

Execute the following command to check the Pod list of a component:

{{< copyable "shell-regular" >}}

```shell
kubectl get pod -n <namespace> -l app.kubernetes.io/component=<component-name>
```

Execute the following command to forcibly restart all Pods of a component:

{{< copyable "shell-regular" >}}

```shell
kubectl delete pod -n <namespace> -l app.kubernetes.io/component=<component-name>
```

> **Note:**
>
> - To forcibly restart all Pods of the `PD`, `TiDB`, or `TiKV` component, replace `<component-name>` in the above commands with `pd`, `tidb`, or `tikv` respectively.
> - Replace `<namespace>` in the above commands with your own namespace.
## Forcibly restart all Pods of the TiDB cluster

Execute the following command to check the Pod list of the TiDB cluster (including `monitor` and `discovery`):

{{< copyable "shell-regular" >}}

```shell
kubectl get pod -n <namespace> -l app.kubernetes.io/instance=<tidb-cluster-name>
```

Execute the following command to forcibly restart all Pods of the TiDB cluster (including `monitor` and `discovery`):

{{< copyable "shell-regular" >}}

```shell
kubectl delete pod -n <namespace> -l app.kubernetes.io/instance=<tidb-cluster-name>
```

> **Note:**
>
> Replace `<namespace>` and `<tidb-cluster-name>` in the above commands with your own namespace and TiDB cluster name.

0 comments on commit a3eb80e

Please sign in to comment.