Официальный Java-клиент Kubernetes добавил, что аутентификация Http завершилась неудачно - PullRequest
0 голосов
/ 30 апреля 2019

Я использую Официальный Java-клиент Kubernetes для доступа к остальным ресурсам API Api-сервера Kubernetes.На основании руководства все в порядке, даже когда я добавляю http-прокси без аутентификации для доступа к ресурсам.Однако, когда я добавляю http-прокси с аутентификацией, происходит сбой и появляется сообщение

. Причина: java.net.ProtocolException: неожиданная строка состояния: 7E6 в com.squareup.okhttp.internal.http.StatusLine.parse (StatusLine.java:54) на com.squareup.okhttp.internal.http.Http1xStream.readResponse (Http1xStream.java:186) на com.squareup.okhttp.internal.io.RealConnection.createTunnel (RealConnection.java:2)в com.squareup.okhttp.internal.io.RealConnection.connectTls (RealConnection.java:172) в com.squareup.okhttp.internal.io.RealConnection.connectSocket (RealConnection.java:149) в com.squareup.okhttp.internal.io.RealConnection.connect (RealConnection.java:112) при com.squareup.okhttp.internal.http.StreamAllocation.findConnection (StreamAllocation.java:184) в com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection (StreamAllocation.java: 126) на com.squareup.okhttp.internal.http.StreamAllocation.newStream (StreamAllocation.java:95) на com.squareup.okhttp.internal.http.HttpEngine.connect (HttpEngine.java:281) на com.squareup.okhttp.internal.http.HttpEngine.sendRequest (HttpEngine.java:224) на com.squareup.okhttp.Call.getResponse (Call.java:286) на com.squareup.okhttp.Call $ ApplicationInterceptorChain.proceed (Call.java:243) в com.squareup.okhttp.Call.getResponseWithInterceptorChain (Call.java:205) в com.squareup.okhttp.Call.execute (Call.java:80)at io.kubernetes.client.ApiClient.execute (ApiClient.java:797) ... еще 4

Может кто-нибудь помочь узнать, как я могу добавить авторизацию для http-прокси официальной Java-версии kubernetesклиент?

Пример кода:

KubeConfig kubeConfig = KubeConfig.loadKubeConfig(new FileReader(CREDENTIAL_PATH));
ApiClient client = ClientBuilder.kubeconfig(kubeConfig).build();
client.getHttpClient().setProxy(
        new Proxy(
                Proxy.Type.HTTP,
                new InetSocketAddress(
                        <proxyAddress>, 
                        <proxyPort>)));
client.getHttpClient().setAuthenticator(
        new Authenticator() {
                @Override
                public Request authenticate(Proxy proxy, Response response) throws IOException {
                    return null;
                }

                @Override
                public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
                    String credential = Credentials.basic(
                            <proxyAuthUsername>, 
                            <proxyAuthPassword>);
                    return response
                            .request()
                            .newBuilder()
                            .header("Proxy-Authorization", credential)
                            .build();
                }
            });
CoreV1Api api = new CoreV1Api(client);
System.out.println(api.listNode(null, null, null, null, null, null, null, null, null).getItems().size());
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...