Java Kubernetes Openshift客户端身份验证
我正在使用openshift 3.9,并尝试使用Fabir8 Kubernetes client()列出我的命名空间中的所有pod。 我在版本中使用Java8和openshift客户端Java Kubernetes Openshift客户端身份验证,java,kubernetes,openshift,fabric8,Java,Kubernetes,Openshift,Fabric8,我正在使用openshift 3.9,并尝试使用Fabir8 Kubernetes client()列出我的命名空间中的所有pod。 我在版本中使用Java8和openshift客户端 <dependency> <groupId>io.fabric8</groupId> <artifactId>openshift-client</artifactId> <version>4.
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
<version>4.1.0</version>
</dependency>
这意味着我的serviceaccount拥有在名称空间中列出POD的权限
使用java时,我无法授权jet
try (OpenShiftClient client = new DefaultOpenShiftClient()) {
System.out.println("Client opened is: " + client.getConfiguration().getOauthToken());
client.pods().list().getItems().stream().forEach(
p -> System.out.println("pod: " + p));
}
即使我使用builderConfig显式地指定客户机,错误如下
随后:
线程“OkHttp Dispatcher”io.fabric8.kubernetes.client.KubernetesClientException中出现异常:对授权请求的意外响应(401未经授权)。缺少标题:[位置]!
位于io.fabric8.openshift.client.internal.OpenShiftOAuthInterceptor.authorize(OpenShiftOAuthInterceptor.java:128)
位于io.fabric8.openshift.client.internal.OpenShiftOAuthInterceptor.intercept(OpenShiftOAuthInterceptor.java:63)
在okhttp3.internal.http.RealInterceptorChain.procedure(RealInterceptorChain.java:92)
在okhttp3.internal.http.RealInterceptorChain.procedure(RealInterceptorChain.java:67)
在okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
在okhttp3.RealCall$AsyncCall.execute(RealCall.java:129)
运行(NamedRunnable.java:32)
位于java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
运行(Thread.java:748)
问题似乎在于这一类:
在第132行中,未设置令牌的位置,因此找不到令牌。
我自己解决不了这个问题。也许我必须自己设置标题授权:持有者
希望有人能帮忙
祝福
乔恩
try (OpenShiftClient client = new DefaultOpenShiftClient()) {
System.out.println("Client opened is: " + client.getConfiguration().getOauthToken());
client.pods().list().getItems().stream().forEach(
p -> System.out.println("pod: " + p));
}