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
@@ -9,7 +9,7 @@ This document describes how to enable TLS for MySQL client of the TiDB cluster o
9
9
10
10
To enable TLS for the MySQL client, perform the following steps:
11
11
12
-
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.
12
+
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.
13
13
14
14
> **Note:**
15
15
>
@@ -20,7 +20,9 @@ To enable TLS for the MySQL client, perform the following steps:
20
20
-[Using the `cfssl` system](#using-cfssl)
21
21
-[Using the `cert-manager` system](#using-cert-manager)
22
22
23
-
2.[Deploy the cluster](#deploy-the-tidb-cluster), and set `.spec.tidb.tlsClient.enabled` to `true`.
23
+
If you need to renew the existing TLS certificate, refer to [Renew and Replace the TLS Certificate](renew-tls-certificate.md).
24
+
25
+
2.[Deploy the cluster](#step-2-deploy-the-tidb-cluster), and set `.spec.tidb.tlsClient.enabled` to `true`.
24
26
25
27
* 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`.
26
28
* 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).
@@ -30,11 +32,9 @@ To enable TLS for the MySQL client, perform the following steps:
30
32
>
31
33
> For an existing cluster, if you change `.spec.tidb.tlsClient.enabled` from `false` to `true`, the TiDB Pods will be rolling restarted.
32
34
33
-
3.[Configure the MySQL client to use an encrypted connection](#configure-the-mysql-client-to-use-an-encrypted-connection).
34
-
35
-
If you need to renew the existing TLS certificate, refer to [Renew and Replace the TLS Certificate](renew-tls-certificate.md).
35
+
3.[Configure the MySQL client to use an encrypted connection](#step-3-configure-the-mysql-client-to-use-a-tls-connection).
36
36
37
-
## Issue two sets of certificates for the TiDB cluster
37
+
## Step 1. Issue two sets of certificates for the TiDB cluster
38
38
39
39
This section describes how to issue certificates for the TiDB cluster using two methods: `cfssl` and `cert-manager`.
40
40
@@ -508,7 +508,7 @@ You can generate multiple sets of client-side certificates. At least one set of
508
508
>
509
509
> 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.
510
510
511
-
## Deploy the TiDB cluster
511
+
## Step 2. Deploy the TiDB cluster
512
512
513
513
In this step, you create a TiDB cluster and perform the following operations:
514
514
@@ -636,16 +636,16 @@ In this step, you create a TiDB cluster and perform the following operations:
636
636
kubectl apply -f restore.yaml
637
637
```
638
638
639
-
## Configure the MySQL client to use an encrypted connection
639
+
## Step 3. Configure the MySQL client to use a TLS connection
640
640
641
641
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).
642
642
643
643
Execute the following command to acquire the client-side certificate and connect to the TiDB server:
644
644
645
645
``` shell
646
-
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.crt}'| base64 --decode > client-tls.crt
647
-
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.key}'| base64 --decode > client-tls.key
648
-
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.ca\.crt}'| base64 --decode > client-ca.crt
646
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.crt}'| base64 --decode > client-tls.crt
647
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.tls\.key}'| base64 --decode > client-tls.key
648
+
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).
656
656
657
+
When not relying on client certificates the following is sufficient:
658
+
659
+
``` shell
660
+
kubectl get secret -n ${namespace}${cluster_name}-tidb-client-secret -ojsonpath='{.data.ca\.crt}'| base64 --decode > client-ca.crt
661
+
```
662
+
663
+
``` shell
664
+
mysql --comments -uroot -p -P 4000 -h ${tidb_host} --ssl-ca=client-ca.crt
665
+
```
666
+
667
+
## Troubleshooting
668
+
669
+
The X.509 certificates are stored in Kubernetes secrets. To inspect them, use commands similar to `kubectl -n ${namespace} get secret`.
670
+
671
+
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.
672
+
673
+
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
@@ -56,7 +56,7 @@ If TLS between components has been enabled on the target TiDB cluster (`spec.tls
56
56
57
57
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.
58
58
59
-
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`.
59
+
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