Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify kubeconfig file location when using fabric8io?

According to this, I can specify system property KUBECONFIG to tell defaultKubernetesClient to use the specified kubeconfig file instead of the default ~/.kube/configfile.
What should I do that then I'm using fabric8io?
Tks in advance.

like image 200
theotheo Avatar asked Oct 20 '25 16:10

theotheo


1 Answers

It looks like there is a typo in the blogpost, If I look at Fabric8 code Config.java, property name is kubeconfig not KUBECONFIG.

I moved my .kube/config file to /tmp/mykubeconfig and then I tested with the following code on minikube and it seemed to be working okay

System.setProperty("kubeconfig", "/tmp/mykubeconfig");
try (KubernetesClient kubernetesClient = new DefaultKubernetesClient()) {
    kubernetesClient.pods().inAnyNamespace().list().getItems().stream()
            .map(Pod::getMetadata)
            .map(ObjectMeta::getName)
            .forEach(System.out::println);
}
like image 98
Rohan Kumar Avatar answered Oct 23 '25 07:10

Rohan Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!