如何解决“名称无法解析”:部署简单的Springboot应用程序以测试REST API时Kubernetes客户端异常?

时间:2019-06-28 13:18:21

标签: kubernetes minikube

我正在尝试部署一个基于springboot框架的应用程序来测试REST API。该应用程序(服务器和客户端)已通过docker容器进行了部署,而kubernetes已被用于容器的部署和管理。问题是,每当我尝试执行查询时,它都会返回此错误:

2019-06-28 10:25:36.343 ERROR 1 --- [nio-8081-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is io.fabric8.kubernetes.client.KubernetesClientException: Operation: [create]  for kind: [Job]  with name: [null]  in namespace: [default]  failed.] with root cause

java.net.UnknownHostException: kubernetes.default.svc: Name does not resolve

我正在使用minikube,并且已经用busbox pod测试了本地部署,并且minikube在本地正确公开了DNS。

这是stacktrace的样子:

java.net.UnknownHostException: kubernetes.default.svc: Name does not resolve
    at java.base/java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:na]
    at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929) ~[na:na]
    at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1515) ~[na:na]
    at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848) ~[na:na]
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505) ~[na:na]
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364) ~[na:na]
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298) ~[na:na]
    at okhttp3.Dns$1.lookup(Dns.java:40) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:185) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:149) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:84) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:214) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.12.0.jar!/:na]
    at io.fabric8.kubernetes.client.utils.BackwardsCompatibilityInterceptor.intercept(BackwardsCompatibilityInterceptor.java:119) ~[kubernetes-client-4.1.3.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.12.0.jar!/:na]
    at io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor.intercept(ImpersonatorInterceptor.java:68) ~[kubernetes-client-4.1.3.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.12.0.jar!/:na]
    at io.fabric8.kubernetes.client.utils.HttpClientUtils.lambda$createHttpClient$1(HttpClientUtils.java:102) ~[kubernetes-client-4.1.3.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254) ~[okhttp-3.12.0.jar!/:na]
    at okhttp3.RealCall.execute(RealCall.java:92) ~[okhttp-3.12.0.jar!/:na]

0 个答案:

没有答案