ApiClient client = Config.defaultClient();
// infinite timeout
OkHttpClient httpClient = client.getHttpClient().newBuilder().connectTimeout(0, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.SECONDS).build();
client.setHttpClient(httpClient);
io.kubernetes.client.openapi.Configuration.setDefaultApiClient(client);
logger.info("use inCluster mode");
logger.info("KUBERNETES_SERVICE: "+client.getBasePath());
return new CoreV1Api(client);
I made sure the network was working
I use the code is very simple
V1PodList list = coreV1Api.listNamespacedPod(serviceName, DEFAULT_PRETTY, false, null, null, null, null, null,
null, 10, false);
Throws an exception
okhttp3.internal.http2.ConnectionShutdownException: null
at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:255)
at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:238)
at okhttp3.internal.http2.Http2ExchangeCodec.writeRequestHeaders(Http2ExchangeCodec.java:116)
at okhttp3.internal.connection.Exchange.writeRequestHeaders(Exchange.java:72)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:43)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at io.kubernetes.client.openapi.ApiClient$2.intercept(ApiClient.java:1270)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at io.kubernetes.client.util.credentials.TokenFileAuthentication.intercept(TokenFileAuthentication.java:72)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
at okhttp3.RealCall.execute(RealCall.java:81)
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:884)
... 100 common frames omitted
please talk me where to conduct relevant checks
Client Version
e.g. 14.0.0
Kubernetes Version
e.g. 1.22
Java Version
e.g. Java 8_251
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
KubeConfig
If applicable, add a KubeConfig file with secrets redacted.
Server (please complete the following information):
OS: [e.g. Linux] centos 7
Environment [e.g. container]
Cloud [e.g. Azure]
Additional context
Add any other context about the problem here.
It appears that you are setting your timeouts to zero seconds? I don't think that is what you want (and I suspect that is what is causing the problem)
Why are you setting timeouts, it shouldn't be needed.
It appears that you are setting your timeouts to zero seconds? I don't think that is what you want (and I suspect that is what is causing the problem)
Why are you setting timeouts, it shouldn't be needed.
That's not the point. It's the same no matter how many settings you have. I've already debugged it
@RequestMapping("/listNamespacedPod")
@ResponseBody
public Object listNamespacedPod(@RequestParam(required = false, defaultValue = "test") String namespace) {
try {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
V1PodList list =
api.listNamespacedPod(namespace, "true", null, null, null, null, null, null, null, null, false);
return list;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return e.getMessage();
when I use it this way, there are still mistakes
i use kubernetes-client
@RequestMapping("/inNamespaceList")
public Object test(@RequestParam(required = false, defaultValue = "luc") String namespace) {
final ConfigBuilder configBuilder = new ConfigBuilder();
try (KubernetesClient client = new DefaultKubernetesClient(configBuilder.build())) {
// Creating namespace
PodList podList = client.pods().inNamespace(namespace).list(new ListOptionsBuilder().withLimit(20L).build());
return podList;
} catch (Exception e) {
logger.error(e.getMessage(), e);
Throwable[] suppressed = e.getSuppressed();
if (suppressed != null) {
for (Throwable t : suppressed) {
logger.error(t.getMessage(), t);
return Collections.emptyList();
as expected, the pod list is returned
but in https://github.com/kubernetes-client/java
ConnectionShutdownException
I don't know what's going on, I've tested it from version 14-16
i use code:
@RequestMapping("/listNamespacedPod")
@ResponseBody
public Object listNamespacedPod(@RequestParam(required = false, defaultValue = "luc") String namespace) {
try {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
V1PodList list =
api.listNamespacedPod(namespace, "true", null, null, null, null, null, null, null, null, false);
return list;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return e.getMessage();
please help me looking ,thx all
when using the http2 protocol, the following parameters are not added
--tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256
k8s version 1.22.3
Given the status quo, this problem is bound to arise
@brendandburns @yue9944882 PTAL