Skip to content

Commit

Permalink
add tls description
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Aug 23, 2024
1 parent 7ba4983 commit e2bc07b
Showing 1 changed file with 65 additions and 23 deletions.
88 changes: 65 additions & 23 deletions zh/enable-tls-between-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,7 @@ aliases: ['/docs-cn/tidb-in-kubernetes/dev/enable-tls-between-components/']
>
> 在集群创建后,不能修改此字段,否则将导致集群升级失败,此时需要删除已有集群,并重新创建。
>
> 集群创建后再开启 tls,在无法重建的情况下,可尝试以下方式(**请谨慎操作**):
>
> 1. 在存在多个 PD 节点的情况下,缩容 PD 至 1 个。(否则可以跳过此步骤)
> 2. 下载 etcdctl。参考 [etcdctl 安装指南](https://etcd.io/docs/v3.4/install/),etcdctl 位于文件夹目录下。
> 3. 设置 `.spec.tlsCluster.enabled` 属性为 `true`
> 4. 查看 etcd member,可见 peerURLs 此时为 http:
> >
> > ```bash
> > etcdctl --endpoints https://127.0.0.1:2379 --cert-file ./pd-tls/tls.crt --key-file ./pd-tls/tls.key --ca-file ./pd-tls/ca.crt member list
> > 输出示例:
> > 8e9e05c52164694d: name=tidb-test-v75-pd-0 peerURLs=http://localhost:2380 clientURLs=https://localhost:2379 isLeader=true
> > ```
> >
> 5. 修改 etcd member 的 peerURLs 为 https:
> >
> > ```bash
> > etcdctl --endpoints https://127.0.0.1:2379 --cert-file ./pd-tls/tls.crt --key-file ./pd-tls/tls.key --ca-file ./pd-tls/ca.crt member update 8e9e05c52164694d --peer-urls="https://localhost:2380"
> > 输出示例:
> > Updated member with ID 8e9e05c52164694d in cluster
> > ```
> >
> 6. 查看此时 etcd member 的 peerURLs 已经修改为 https。
> 7. 若缩容过 PD 节点,需先扩容至原有数量。(否则可以跳过此步骤)
> 在无法重建的情况下,如果希望集群创建后再开启 TLS,可尝试[以下方式](#从非-tls-集群升级到-tls-集群)**请谨慎操作**):
3. 配置 `pd-ctl``tikv-ctl` 连接集群。

Expand Down Expand Up @@ -1680,3 +1658,67 @@ aliases: ['/docs-cn/tidb-in-kubernetes/dev/enable-tls-between-components/']
cd /var/lib/cluster-client-tls
/tikv-ctl --ca-path=ca.crt --cert-path=tls.crt --key-path=tls.key --host 127.0.0.1:20160 cluster
```
## 从非 TLS 集群升级到 TLS 集群
> **注意:请谨慎操作**
>
> 在集群无法重建的情况下,适用于集群创建后再开启 TLS。
>
1. 如果存在多个 PD 节点,缩容 PD 至 1 个节点。
2. 参考 [第一步:为 TiDB 集群各个组件生成证书](#第一步为-tidb-集群各个组件生成证书) ,准备证书及创建 Kubernetes Secret 对象。
3. 参考 [第二步:部署 TiDB 集群](#第二步部署-tidb-集群) ,修改 `tidb-cluster.yaml` 文件,使用 `kubectl apply -f tidb-cluster.yaml` 来更新 TiDB 集群。
4. 登录 PD pod,下载 etcdctl。参考 [etcdctl 安装指南](https://etcd.io/docs/v3.4/install/),etcdctl 位于解压后的文件夹目录下。
5. 查看 etcd member,可见 peerURLs 此时为 http:
```bash
./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
```
输出示例:
```bash
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
```
**示例解释:**
memberID 和 peerURLs 需要在下个步骤更新 member 时填入:
1. 包含 memberID,示例中为第一项 `e94cfb12fa384e23`
2. 包含 peerURLs,示例中为第三项 `http://basic-pd-0.basic-pd-peer.pingcap.svc:2380`
6. 修改 etcd member 的 peerURLs 为 https:
**注意:**
peerURLS 需要修改 `http``https`
```bash
./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"
```
输出示例:
```bash
Member e94cfb12fa384e23 updated in cluster 32ab5936d81ad54c
```
7. 查看此时 etcd member 的 peerURLs,确认已经修改为 https:
```bash
./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
```
输出示例:
```bash
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
```
此时 peerURLs 已更新为 `https://basic-pd-0.basic-pd-peer.pingcap.svc:2380`
8. 若缩容过 PD 节点,需扩容 PD 至原有数量。
9. 等待其他 pod 重启更新。

0 comments on commit e2bc07b

Please sign in to comment.