External Application Fails to Access TiDB Cluster Deployed on K8s

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 外部应用访问K8s搭建的Tidb集群失败

| username: China-Dwan

【TiDB Usage Environment】Production\Test Environment\POC
Test Environment

【TiDB Version】
5.4.1

【Encountered Problem】
An external Spark cluster needs to access the TiDB cluster deployed on K8s. There is an issue with domain name resolution.

【Reproduction Path】
【Problem Phenomenon and Impact】

【TiDB Operator Version】:
1.3

【K8s Version】:

【Attachments】:

| username: wakaka | Original post link

The TiDB domain name in k8s is for internal access within the k8s cluster. If you need to access it externally, you first need to map the k8s access address.

| username: China-Dwan | Original post link

Do we need to map all deployed pods? What IP should they be mapped to? If they are mapped to the pod, how do we solve the pod IP drift problem?

| username: wfxxh | Original post link

NodePort, create the service yourself, and use the selector to select the corresponding component. You are using TiSpark to access PD. If it’s on YARN, there might be an issue because PD returns internal addresses, and you need to know the host on all nodes. If it’s on K8s, there won’t be any problem.

| username: China-Dwan | Original post link

In the on yarn mode, because it is not in the same cluster, there will be parsing issues. So two problems need to be addressed. 1. DNS resolution of internal domain names in k8s, which has already been resolved. 2. The issue of pod IP drift, where the pod’s IP changes after being restarted. Do you have any good suggestions?

| username: yilong | Original post link

Does TiDB Operator support TiSpark?

| username: MyronWang | Original post link

  1. Directly use k8s’s NodePort.
    Change the service type of the TiDB component to NodePort, so you can access the TiDB service using “any” k8s node IP + NodePort.

    It is recommended to specify the NodePort port, so the port will not change unexpectedly. It is also recommended to use a “stable” node’s IP, meaning this node will not be “easily” scaled down.

  2. Create a domain name on an external DNS server that points to the IP from the first step.
    This way, you can normally use the domain name to access the TiDB service in k8s. (It’s just an external domain name)
| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.