# [KB]关于TiSpark 连接 TiDB 集群报错 java.lang.NullPointerException Failed to init client for PD cluster

## Issue

使用 TiSpark 连接 TiDB 集群报错 java.lang.NullPointerException: Failed to init client for PD cluster

## Root Cause

TiSpark 使用 ELB 访问 Kubernetes 内 PD Service Endpoint 时， endpoint 可能绑定 PD Follower 和 PD Leader，并且是负载均衡的，如果流量被均衡到 PD Follower，PD 对于 Http 请求会转发到 Leader，对于 TCP 请求会跳转到 Leader。 TiSpark 连接 PD 是 TCP 请求，当跳转到一个内网地址时请求会失败

## Diagnostic Steps

查看客户端返回如下报错：

```golang
WARN PDClient: failed to get member from pd server.
shade.io.grpc.StatusRuntimeException: INTERNAL: http2 exception
  at shade.io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:244)
  ...
  at com.patsnap.tispark.App.main(App.java:21)
Caused by: shade.io.netty.handler.codec.http2.Http2Exception: First received frame was not SETTINGS. Hex dump for first 5 bytes: 485454502f
  at shade.io.netty.handler.codec.http2.Http2Exception.connectionError(Http2Exception.java:103)
  ...
  at java.lang.Thread.run(Thread.java:748)
Exception in thread "main" java.lang.NullPointerException: Failed to init client for PD cluster.
  at com.pingcap.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:906)
  ....
  at com.patsnap.tispark.App.main(App.java:21)
```

## Resolution

需要在同一 Kubernetes 集群内部署 TiSpark

## Workaround

N/A
