ROBO Example: Backup BE code
[ealt-edge.git] / example-apps / ROBO / backup_BE / src / main / java / org / edgegallery / example_app / backupApplication.java
1 package org.edgegallery.example_app;
2
3
4 import io.kubernetes.client.ApiException;
5 import io.kubernetes.client.Configuration;
6 import io.kubernetes.client.apis.CoreV1Api;
7 import io.kubernetes.client.models.V1PersistentVolumeClaim;
8 import io.kubernetes.client.models.V1PersistentVolumeClaimList;
9 import io.kubernetes.client.util.ClientBuilder;
10 import io.kubernetes.client.util.KubeConfig;
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.edgegallery.example_app.model.Pvcs;
14 import org.springframework.boot.SpringApplication;
15 import org.springframework.boot.autoconfigure.SpringBootApplication;
16 import io.kubernetes.client.ApiClient;
17 import org.springframework.context.annotation.Bean;
18 import java.io.FileReader;
19 import java.io.IOException;
20
21 @SpringBootApplication
22 public class backupApplication {
23
24     @Bean
25     public static void apiclient() throws IOException {
26         // file path to your KubeConfig
27         String homePath = System.getenv("HOME");
28         String kubeConfigPath = homePath + "/.kube/config";
29
30         // loading the out-of-cluster config, a kubeconfig from file-system
31         ApiClient client =
32                 ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath))).build();
33
34         // set the global default api-client to the in-cluster one from above
35         Configuration.setDefaultApiClient(client);
36     }
37
38     public static void main(String[] args) throws IOException {
39         SpringApplication.run(backupApplication.class, args);
40     }
41 }