You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/enable-tls-for-mysql-client.md
+56-11Lines changed: 56 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ This document describes how to enable TLS for MySQL client of the TiDB cluster o
10
10
11
11
To enable TLS for the MySQL client, perform the following steps:
12
12
13
-
1.[Issue two sets of certificates](#issue-two-sets-of-certificates-for-the-tidb-cluster): a set of server-side certificates for TiDB server, and a set of client-side certificates for MySQL client. Create two Secret objects, `${cluster_name}-tidb-server-secret` and `${cluster_name}-tidb-client-secret`, respectively including these two sets of certificates.
13
+
1.[Issue two sets of certificates](#step-1-issue-two-sets-of-certificates-for-the-tidb-cluster): a set of server-side certificates for TiDB server, and a set of client-side certificates for MySQL client. Create two Secret objects, `${cluster_name}-tidb-server-secret` and `${cluster_name}-tidb-client-secret`, respectively including these two sets of certificates.
14
14
15
15
> **Note:**
16
16
>
@@ -21,7 +21,9 @@ To enable TLS for the MySQL client, perform the following steps:
21
21
-[Using the `cfssl` system](#using-cfssl)
22
22
-[Using the `cert-manager` system](#using-cert-manager)
23
23
24
-
2.[Deploy the cluster](#deploy-the-tidb-cluster), and set `.spec.tidb.tlsClient.enabled` to `true`.
24
+
If you need to renew the existing TLS certificate, refer to [Renew and Replace the TLS Certificate](renew-tls-certificate.md).
25
+
26
+
2.[Deploy the cluster](#step-2-deploy-the-tidb-cluster), and set `.spec.tidb.tlsClient.enabled` to `true`.
25
27
26
28
* To skip TLS authentication for internal components that serve as the MySQL client (such as TidbInitializer, Dashboard, Backup, and Restore), you can add the `tidb.tidb.pingcap.com/skip-tls-when-connect-tidb="true"` annotation to the cluster's corresponding `TidbCluster`.
27
29
* To disable the client CA certificate authentication on the TiDB server, you can set `.spec.tidb.tlsClient.disableClientAuthn` to `true`. This means skipping setting the `ssl-ca` parameter when you [configure TiDB server to enable secure connections](https://docs.pingcap.com/tidb/stable/enable-tls-between-clients-and-servers#configure-tidb-server-to-use-secure-connections).
@@ -31,11 +33,9 @@ To enable TLS for the MySQL client, perform the following steps:
31
33
>
32
34
> For an existing cluster, if you change `.spec.tidb.tlsClient.enabled` from `false` to `true`, the TiDB Pods will be rolling restarted.
33
35
34
-
3.[Configure the MySQL client to use an encrypted connection](#configure-the-mysql-client-to-use-an-encrypted-connection).
35
-
36
-
If you need to renew the existing TLS certificate, refer to [Renew and Replace the TLS Certificate](renew-tls-certificate.md).
36
+
3.[Configure the MySQL client to use an encrypted connection](#step-3-configure-the-mysql-client-to-use-a-tls-connection).
37
37
38
-
## Issue two sets of certificates for the TiDB cluster
38
+
## Step 1. Issue two sets of certificates for the TiDB cluster
39
39
40
40
This section describes how to issue certificates for the TiDB cluster using two methods: `cfssl` and `cert-manager`.
41
41
@@ -509,7 +509,7 @@ You can generate multiple sets of client-side certificates. At least one set of
509
509
>
510
510
> TiDB server's TLS is compatible with the MySQL protocol. When the certificate content is changed, the administrator needs to manually execute the SQL statement `alter instance reload tls` to refresh the content.
511
511
512
-
## Deploy the TiDB cluster
512
+
## Step 2. Deploy the TiDB cluster
513
513
514
514
In this step, you create a TiDB cluster and perform the following operations:
515
515
@@ -637,16 +637,16 @@ In this step, you create a TiDB cluster and perform the following operations:
637
637
kubectl apply -f restore.yaml
638
638
```
639
639
640
-
## Configure the MySQL client to use an encrypted connection
640
+
## Step 3. Configure the MySQL client to use a TLS connection
641
641
642
642
To connect the MySQL client with the TiDB cluster, use the client-side certificate created above and take the following methods. For details, refer to [Configure the MySQL client to use encrypted connections](https://docs.pingcap.com/tidb/stable/enable-tls-between-clients-and-servers#configure-the-mysql-client-to-use-encrypted-connections).
643
643
644
644
Execute the following command to acquire the client-side certificate and connect to the TiDB server:
645
645
646
646
``` shell
647
-
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.crt}'| base64 --decode > client-tls.crt
648
-
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.key}'| base64 --decode > client-tls.key
649
-
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.ca\.crt}'| base64 --decode > client-ca.crt
647
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.crt}'| base64 --decode > client-tls.crt
648
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.key}'| base64 --decode > client-tls.key
649
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.ca\.crt}'| base64 --decode > client-ca.crt
Finally, to verify whether TLS is successfully enabled, refer to [checking the current connection](https://docs.pingcap.com/tidb/stable/enable-tls-between-clients-and-servers#check-whether-the-current-connection-uses-encryption).
657
657
658
+
When not relying on client certificates the following is sufficient:
659
+
660
+
``` shell
661
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.ca\.crt}'| base64 --decode > client-ca.crt
662
+
```
663
+
664
+
``` shell
665
+
mysql --comments -uroot -p -P 4000 -h ${tidb_host} --ssl-ca=client-ca.crt
666
+
```
667
+
668
+
## Troubleshooting
669
+
670
+
The X.509 certificates are stored in Kubernetes secrets. To inspect them, use commands similar to `kubectl -n ${namespace} get secret`.
671
+
672
+
These secrets are mounted into the containers. To view the volume mounts, check the **Volumes** section in the output of the `kubectl -n ${namespace} describe pod ${podname}` command.
673
+
674
+
To check these secret mounts from inside the container, run the following command:
Copy file name to clipboardExpand all lines: en/restore-data-using-tidb-lightning.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ If TLS between components has been enabled on the target TiDB cluster (`spec.tls
57
57
58
58
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.
59
59
60
-
To use different client certificates to connect to the TiDB server, refer to [Issue two sets of certificates for the TiDB cluster](enable-tls-for-mysql-client.md#issue-two-sets-of-certificates-for-the-tidb-cluster) to generate the client-side certificate for TiDB Lightning, and configure the corresponding Kubernetes secret object in `tlsCluster.tlsClientSecretName` in `values.yaml`.
60
+
To use different client certificates to connect to the TiDB server, refer to [Issue two sets of certificates for the TiDB cluster](enable-tls-for-mysql-client.md#step-1-issue-two-sets-of-certificates-for-the-tidb-cluster) to generate the client-side certificate for TiDB Lightning, and configure the corresponding Kubernetes secret object in `tlsCluster.tlsClientSecretName` in `values.yaml`.
0 commit comments