Added Authentication Component
[eliot.git] / blueprints / common / eliot-ui / be / src / eliotk8sclient / src / main / java / com / eliot / eliotbe / eliotk8sclient / Eliotk8sclientApplication.java
1 package com.eliot.eliotbe.eliotk8sclient;
2
3
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;
13
14
15 @SpringBootApplication
16 public class Eliotk8sclientApplication {
17
18         @Bean
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";
23
24                 // loading the out-of-cluster config, a kubeconfig from file-system
25                 ApiClient client =
26                                 ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath))).build();
27
28                 // set the global default api-client to the in-cluster one from above
29                 Configuration.setDefaultApiClient(client);
30         }
31         public static void main(String[] args) {
32                 SpringApplication.run(Eliotk8sclientApplication.class, args);
33         }
34
35 }