added docker and kubenetes yaml file
[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         String kubeConfigPath = System.getenv("KUBE_CONFIG");
30
31         // loading the out-of-cluster config, a kubeconfig from file-system
32         ApiClient client =
33                 ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath))).build();
34
35         // set the global default api-client to the in-cluster one from above
36         Configuration.setDefaultApiClient(client);
37     }
38
39     public static void main(String[] args) throws IOException {
40         SpringApplication.run(backupApplication.class, args);
41     }
42 }