Skip to content

Commit 4a88e2c

Browse files
authored
pd/tls: add upgrade tls description (#2710) (#2711)
1 parent 83eebb4 commit 4a88e2c

File tree

4 files changed

+94
-6
lines changed

4 files changed

+94
-6
lines changed

en/configure-a-tidb-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ It is recommended that you configure `spec.pvReclaimPolicy: Retain` to ensure th
6868

6969
#### mountClusterClientSecret
7070

71-
PD and TiKV supports configuring `mountClusterClientSecret`. If [TLS is enabled between cluster components](enable-tls-between-components.md), it is recommended to configure `spec.pd.mountClusterClientSecret: true` and `spec.tikv.mountClusterClientSecret: true`. Under such configuration, TiDB Operator automatically mounts the `${cluster_name}-cluster-client-secret` certificate to the PD and TiKV container, so you can conveniently [use `pd-ctl` and `tikv-ctl`](enable-tls-between-components.md#configure-pd-ctl-tikv-ctl-and-connect-to-the-cluster).
71+
PD and TiKV supports configuring `mountClusterClientSecret`. If [TLS is enabled between cluster components](enable-tls-between-components.md), it is recommended to configure `spec.pd.mountClusterClientSecret: true` and `spec.tikv.mountClusterClientSecret: true`. Under such configuration, TiDB Operator automatically mounts the `${cluster_name}-cluster-client-secret` certificate to the PD and TiKV container, so you can conveniently [use `pd-ctl` and `tikv-ctl`](enable-tls-between-components.md#step-3-configure-pd-ctl-tikv-ctl-and-connect-to-the-cluster).
7272

7373
#### startScriptVersion
7474

en/enable-tls-between-components.md

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ To enable TLS between TiDB components, perform the following steps:
2222

2323
> **Note:**
2424
>
25-
> After the cluster is created, do not modify this field; otherwise, the cluster will fail to upgrade. If you need to modify this field, delete the cluster and create a new one.
25+
> - After the cluster is created, do not modify this field; otherwise, the cluster will fail to upgrade. If you need to modify this field, delete the cluster and create a new one.
26+
> - If you cannot rebuild the cluster but need to enable TLS, see [Upgrade a non-TLS cluster to a TLS cluster](#upgrade-a-non-tls-cluster-to-a-tls-cluster).
2627
2728
3. Configure `pd-ctl` and `tikv-ctl` to connect to the cluster.
2829

@@ -38,7 +39,7 @@ Certificates can be issued in multiple methods. This document describes two meth
3839

3940
If you need to renew the existing TLS certificate, refer to [Renew and Replace the TLS Certificate](renew-tls-certificate.md).
4041

41-
## Generate certificates for components of the TiDB cluster
42+
## Step 1. Generate certificates for components of the TiDB cluster
4243

4344
This section describes how to issue certificates using two methods: `cfssl` and `cert-manager`.
4445

@@ -1306,7 +1307,7 @@ This section describes how to issue certificates using two methods: `cfssl` and
13061307
13071308
After the object is created, `cert-manager` generates a `${cluster_name}-cluster-client-secret` Secret object to be used by the clients of the TiDB components.
13081309
1309-
## Deploy the TiDB cluster
1310+
## Step 2. Deploy the TiDB cluster
13101311
13111312
When you deploy a TiDB cluster, you can enable TLS between TiDB components, and set the `cert-allowed-cn` configuration item (for TiDB, the configuration item is `cluster-verify-cn`) to verify the CN (Common Name) of each component's certificate.
13121313
@@ -1516,7 +1517,7 @@ In this step, you need to perform the following operations:
15161517
kubectl apply -f restore.yaml
15171518
```
15181519
1519-
## Configure `pd-ctl`, `tikv-ctl` and connect to the cluster
1520+
## Step 3. Configure `pd-ctl`, `tikv-ctl` and connect to the cluster
15201521
15211522
1. Mount the certificates.
15221523
@@ -1570,3 +1571,89 @@ In this step, you need to perform the following operations:
15701571
cd /var/lib/cluster-client-tls
15711572
/tikv-ctl --ca-path=ca.crt --cert-path=tls.crt --key-path=tls.key --host 127.0.0.1:20160 cluster
15721573
```
1574+
1575+
## Upgrade a non-TLS cluster to a TLS cluster
1576+
1577+
This section describes how to enable TLS encrypted communication for an existing non-TLS TiDB cluster.
1578+
1579+
> **Note:**
1580+
>
1581+
> This operation is only applicable to existing clusters that cannot be rebuilt. Before starting, make sure that you fully understand each step and its potential risks.
1582+
1583+
1. If the cluster contains multiple PD nodes, first reduce the number of PD nodes to 1.
1584+
1585+
2. Refer to [Step 1. Generate certificates for components of the TiDB Cluster](#step-1-generate-certificates-for-components-of-the-tidb-cluster) to generate TLS certificates and create Kubernetes Secret objects.
1586+
1587+
3. Enable TLS:
1588+
1589+
You can choose one of the following methods to enable TLS:
1590+
1591+
- Method 1: Execute the following command to update the TiDB cluster configuration. Wait for the PD Pod to restart before proceeding to the next step.
1592+
1593+
```shell
1594+
kubectl patch tc ${cluster_name} -n ${namespace} --type merge -p '{
1595+
"spec": {
1596+
"tlsCluster": {
1597+
"enabled": true
1598+
}
1599+
}
1600+
}'
1601+
```
1602+
1603+
Example output:
1604+
1605+
```shell
1606+
tidbcluster.pingcap.com/basic patched
1607+
```
1608+
1609+
- Method 2: Refer to [Step 2. Deploy the TiDB cluster](#step-2-deploy-the-tidb-cluster) to enable TLS and set the `cert-allowed-cn` configuration item (for TiDB, the configuration item is `cluster-verify-cn`) to verify the CN (Common Name) of each component's certificate.
1610+
1611+
4. Configure PD nodes:
1612+
1613+
1. Use `kubectl exec` to enter the PD Pod and install `etcdctl`. For detailed installation steps, see the [etcdctl installation guide](https://etcd.io/docs/v3.4/install/). After installation, `etcdctl` is located in the extracted folder directory.
1614+
1615+
2. View the etcd member information. At this point, `peerURLs` use the HTTP protocol:
1616+
1617+
```shell
1618+
./etcdctl --endpoints https://127.0.0.1:2379 --cert /var/lib/pd-tls/tls.crt --key /var/lib/pd-tls/tls.key --cacert /var/lib/pd-tls/ca.crt member list
1619+
```
1620+
1621+
Example output:
1622+
1623+
```shell
1624+
# memberID status name peerURLs clientURL isLearner
1625+
e94cfb12fa384e23, started, basic-pd-0, http://basic-pd-0.basic-pd-peer.pingcap.svc:2380, https://basic-pd-0.basic-pd-peer.pingcap.svc:2379, false
1626+
```
1627+
1628+
Record the following information for the next step:
1629+
1630+
- `memberID`: In the example, it is `e94cfb12fa384e23`.
1631+
- `peerURLs`: In the example, it is `http://basic-pd-0.basic-pd-peer.pingcap.svc:2380`.
1632+
1633+
3. Update the etcd member's `peerURLs` from HTTP to the HTTPS protocol:
1634+
1635+
```shell
1636+
./etcdctl --endpoints https://127.0.0.1:2379 --cert /var/lib/pd-tls/tls.crt --key /var/lib/pd-tls/tls.key --cacert /var/lib/pd-tls/ca.crt member update e94cfb12fa384e23 --peer-urls="https://basic-pd-0.basic-pd-peer.pingcap.svc:2380"
1637+
```
1638+
1639+
Example output:
1640+
1641+
```shell
1642+
Member e94cfb12fa384e23 updated in cluster 32ab5936d81ad54c
1643+
```
1644+
1645+
4. View the updated `peerURLs` to ensure they have been updated to the HTTPS protocol:
1646+
1647+
```shell
1648+
./etcdctl --endpoints https://127.0.0.1:2379 --cert /var/lib/pd-tls/tls.crt --key /var/lib/pd-tls/tls.key --cacert /var/lib/pd-tls/ca.crt member list
1649+
```
1650+
1651+
Example output:
1652+
1653+
```shell
1654+
e94cfb12fa384e23, started, basic-pd-0, https://basic-pd-0.basic-pd-peer.pingcap.svc:2380, https://basic-pd-0.basic-pd-peer.pingcap.svc:2379, false
1655+
```
1656+
1657+
5. If you previously scaled down the PD nodes, scale them back up to the original number.
1658+
1659+
6. Wait for all Pods in the TiDB cluster to restart.

en/restore-data-using-tidb-lightning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ For versions earlier than v1.1.10, you can modify `config` in `values.yaml` to s
5252

5353
#### Configure TLS
5454

55-
If TLS between components has been enabled on the target TiDB cluster (`spec.tlsCluster.enabled: true`), refer to [Generate certificates for components of the TiDB cluster](enable-tls-between-components.md#generate-certificates-for-components-of-the-tidb-cluster) to genereate a server-side certificate for TiDB Lightning, and configure `tlsCluster.enabled: true` in `values.yaml` to enable TLS between components.
55+
If TLS between components has been enabled on the target TiDB cluster (`spec.tlsCluster.enabled: true`), refer to [Generate certificates for components of the TiDB cluster](enable-tls-between-components.md#step-1-generate-certificates-for-components-of-the-tidb-cluster) to generate a server-side certificate for TiDB Lightning, and configure `tlsCluster.enabled: true` in `values.yaml` to enable TLS between components.
5656

5757
If the target TiDB cluster has enabled TLS for the MySQL client (`spec.tidb.tlsClient.enabled: true`), and the corresponding client-side certificate is configured (the Kubernetes Secret object is `${cluster_name}-tidb-client-secret`), you can configure `tlsClient.enabled: true` in `values.yaml` to enable TiDB Lightning to connect to the TiDB server using TLS.
5858

zh/enable-tls-between-components.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,4 +1631,5 @@ summary: 在 Kubernetes 上如何为 TiDB 集群组件间开启 TLS。
16311631
```
16321632
16331633
5. 如果之前进行了 PD 节点缩容,请将其扩容为原有数量。
1634+
16341635
6. 等待 TiDB 集群中的所有 Pod 完成重启。

0 commit comments

Comments
 (0)