1 package com.eliot.eliotbe.eliotk8sclient;
4 import io.kubernetes.client.Configuration;
5 import io.kubernetes.client.util.ClientBuilder;
6 import io.kubernetes.client.util.KubeConfig;
7 import org.springframework.boot.SpringApplication;
8 import org.springframework.boot.autoconfigure.SpringBootApplication;
9 import io.kubernetes.client.ApiClient;
10 import org.springframework.context.annotation.Bean;
11 import java.io.FileReader;
12 import java.io.IOException;
15 @SpringBootApplication
16 public class Eliotk8sclientApplication {
19 public static void apiclient() throws IOException {
20 // file path to your KubeConfig
21 String homePath = System.getenv("HOME");
22 String kubeConfigPath = homePath + "/.kube/config";
24 // loading the out-of-cluster config, a kubeconfig from file-system
26 ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath))).build();
28 // set the global default api-client to the in-cluster one from above
29 Configuration.setDefaultApiClient(client);
31 public static void main(String[] args) {
32 SpringApplication.run(Eliotk8sclientApplication.class, args);