<p>Iam able to connect to Kubernetes cluster using Fabric8 api with the following code :</p>
<pre><code>            String masterUrl = &quot;&lt;Kube Master Url&gt;&quot;;
            Map&lt;String, String&gt; certFileNamesMap = getCertificates();
            Config config = new ConfigBuilder().withMasterUrl(masterUrl).build();
            config.setWebsocketPingInterval(30000L);
            config.setConnectionTimeout(300000);
            config.setRequestTimeout(300000);
            if (certFileNamesMap != null) {
                config.setCaCertFile(certFileNamesMap.get(CA_CERT_FILE));
                config.setClientCertFile(certFileNamesMap.get(CLIENT_CERT_FILE));
                config.setClientKeyFile(certFileNamesMap.get(CLIENT_KEY_FILE));
            }
            KubernetesClient client = new DefaultKubernetesClient(config);
</code></pre>
<p>I am able to set the certificates and able to connect to https://MasterIP but with <a href="https://github.com/kubernetes-client/java" rel="nofollow noreferrer">https://github.com/kubernetes-client/java</a> API I'm not able to figure out the way to set the certs as well as remote master IP. Is there anyway to do that with official kubernetes client API? as fabric8 API is officially discontinued by their team.</p>
<p>Im trying with the following code inside container in minikube :</p>
<pre><code>            ApiClient client = ClientBuilder.cluster().build();
            Configuration.setDefaultApiClient(client);
            System.out.println(&quot;Loading in app cluster 3&quot;);
            CoreV1Api api = new CoreV1Api();
            V1PodList list =
                    api.listPodForAllNamespaces(null,
                            null,
                            null,
                            null,
                            100,
                            null,
                            null,
                            null,
                            null,
                            null);
            System.out.println(&quot;Listing all pods: &quot;);
            for (V1Pod item : list.getItems()) {
                System.out.println(item.getMetadata().getName());
            }
</code></pre>
<p>Im getting error as forbidden.</p>
<pre><code>io.kubernetes.client.openapi.ApiException: Forbidden
at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:993)
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:905)
at io.kubernetes.client.openapi.apis.CoreV1Api.listPodForAllNamespacesWithHttpInfo(CoreV1Api.java:35956)
at io.kubernetes.client.openapi.apis.CoreV1Api.listPodForAllNamespaces(CoreV1Api.java:35848)
</code></pre>

<p>Iam able to figure out the way, we need to use /.kube/config file and copy all the certificates into that file itself, then there is an api in kubernetes java client which reads the config file and gives access to kube cluster.</p>
