Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh: TiCDC TLS document #590

Merged
merged 7 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion zh/deploy-ticdc.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ summary: 了解如何在 Kubernetes 上部署 TiCDC。
{{< copyable "shell-regular" >}}

```shell
/cdc cli capture list --pd=${pd_address}:2379
/cdc cli capture list --pd=http://${cluster_name}-pd:2379
```

```shell
Expand All @@ -73,4 +73,14 @@ summary: 了解如何在 Kubernetes 上部署 TiCDC。
]
```

TiCDC 从 v4.0.3 版本开始支持 TLS,TiDB Operator v1.1.3 版本同步支持 TiCDC 开启 TLS 功能。

如果在创建 TiDB 集群时开启了 TLS,使用 `cdc cli` 请携带 TLS 证书相关参数:

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

```shell
/cdc cli capture list --pd=https://${cluster_name}-pd:2379 --ca=/var/lib/cluster-client-tls/ca.crt --cert=/var/lib/cluster-client-tls/tls.crt --key=/var/lib/cluster-client-tls/tls.key
```

如果服务器没有外网,请参考 [部署 TiDB 集群](deploy-on-general-kubernetes.md#部署-tidb-集群) 在有外网的机器上将用到的 Docker 镜像下载下来并上传到服务器上。
102 changes: 102 additions & 0 deletions zh/enable-tls-between-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,47 @@ summary: 在 Kubernetes 上如何为 TiDB 集群组件间开启 TLS。
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=internal drainer-server.json | cfssljson -bare drainer-server
```

- TiCDC Server 端证书

首先生成默认的 `ticdc-server.json` 文件:

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

``` shell
cfssl print-defaults csr > ticdc-server.json
```

然后编辑这个文件,修改 `CN`,`hosts` 属性:

``` json
...
"CN": "TiDB",
"hosts": [
"127.0.0.1",
"::1",
"${cluster_name}-ticdc",
"${cluster_name}-ticdc.${namespace}",
"${cluster_name}-ticdc.${namespace}.svc",
"${cluster_name}-ticdc-peer",
"${cluster_name}-ticdc-peer.${namespace}",
"${cluster_name}-ticdc-peer.${namespace}.svc",
"*.${cluster_name}-ticdc-peer",
"*.${cluster_name}-ticdc-peer.${namespace}",
"*.${cluster_name}-ticdc-peer.${namespace}.svc"
],
...
```

其中 `${cluster_name}` 为集群的名字,`${namespace}` 为 TiDB 集群部署的命名空间,用户也可以添加自定义 `hosts`。

最后生成 TiCDC Server 端证书:

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

``` shell
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=internal ticdc-server.json | cfssljson -bare ticdc-server
```

6. 生成 Client 端证书。

首先生成默认的 `client.json` 文件:
Expand Down Expand Up @@ -807,6 +848,67 @@ summary: 在 Kubernetes 上如何为 TiDB 集群组件间开启 TLS。

创建这个对象以后,`cert-manager` 会生成一个名字为 `${cluster_name}-drainer-cluster-secret` 的 Secret 对象供 TiDB 集群的 Drainer 组件使用。

- TiCDC 组件的 Server 端证书。
weekface marked this conversation as resolved.
Show resolved Hide resolved

TiCDC 从 v4.0.3 版本开始支持 TLS,TiDB Operator v1.1.3 版本同步支持 TiCDC 开启 TLS 功能。

``` yaml
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: ${cluster_name}-ticdc-cluster-secret
namespace: ${namespace}
spec:
secretName: ${cluster_name}-ticdc-cluster-secret
duration: 8760h # 365d
renewBefore: 360h # 15d
organization:
- PingCAP
commonName: "TiDB"
usages:
- server auth
- client auth
dnsNames:
- "${cluster_name}-ticdc"
- "${cluster_name}-ticdc.${namespace}"
- "${cluster_name}-ticdc.${namespace}.svc"
- "${cluster_name}-ticdc-peer"
- "${cluster_name}-ticdc-peer.${namespace}"
- "${cluster_name}-ticdc-peer.${namespace}.svc"
- "*.${cluster_name}-ticdc-peer"
- "*.${cluster_name}-ticdc-peer.${namespace}"
- "*.${cluster_name}-ticdc-peer.${namespace}.svc"
ipAddresses:
- 127.0.0.1
- ::1
issuerRef:
name: ${cluster_name}-tidb-issuer
kind: Issuer
group: cert-manager.io
```

其中 `${cluster_name}` 为集群的名字:

- `spec.secretName` 请设置为 `${cluster_name}-ticdc-cluster-secret`;
- `usages` 请添加上 `server auth` 和 `client auth`;
- `dnsNames` 需要填写这些 DNS,根据需要可以填写其他 DNS:
- `${cluster_name}-ticdc`
- `${cluster_name}-ticdc.${namespace}`
- `${cluster_name}-ticdc.${namespace}.svc`
- `${cluster_name}-ticdc-peer`
- `${cluster_name}-ticdc-peer.${namespace}`
- `${cluster_name}-ticdc-peer.${namespace}.svc`
- `*.${cluster_name}-ticdc-peer`
- `*.${cluster_name}-ticdc-peer.${namespace}`
- `*.${cluster_name}-ticdc-peer.${namespace}.svc`
- `ipAddresses` 需要填写这两个 IP,根据需要可以填写其他 IP:
- `127.0.0.1`
- `::1`
- `issuerRef` 请填写上面创建的 Issuer;
- 其他属性请参考 [cert-manager API](https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1alpha2.CertificateSpec)。

创建这个对象以后,`cert-manager` 会生成一个名字为 `${cluster_name}-ticdc-cluster-secret` 的 Secret 对象供 TiDB 集群的 TiCDC 组件使用。

- 一套 TiDB 集群组件的 Client 端证书。

``` yaml
Expand Down