Commit 889d5e03 authored by Stephen Nimmo's avatar Stephen Nimmo
Browse files

Updated KubernetesAdminConfiguration to support multiple active profiles

parent af275f94
Pipeline #77442 failed with stage
in 1 minute and 13 seconds
......@@ -8,6 +8,7 @@ import io.kubernetes.client.util.KubeConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import java.io.FileReader;
import java.io.IOException;
......@@ -15,20 +16,31 @@ import java.io.IOException;
@Configuration
public class KubernetesAdminConfiguration {
public KubernetesAdminConfiguration(@Value("${KUBECONFIG}") String kubeConfigPath) throws IOException {
@Bean
@Profile("local")
public ApiClient apiClient(@Value("${KUBECONFIG}") String kubeConfigPath) throws IOException {
KubeConfig kubeConfig = KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath));
ApiClient client = ClientBuilder.kubeconfig(kubeConfig).build();
io.kubernetes.client.openapi.Configuration.setDefaultApiClient(client);
client.setDebugging(true);
ApiClient apiClient = ClientBuilder.kubeconfig(kubeConfig).build();
io.kubernetes.client.openapi.Configuration.setDefaultApiClient(apiClient);
apiClient.setDebugging(true);
return apiClient;
}
@Bean
@Profile("!local")
public ApiClient apiClient() throws IOException {
ApiClient apiClient = ClientBuilder.defaultClient();
io.kubernetes.client.openapi.Configuration.setDefaultApiClient(apiClient);
return apiClient;
}
@Bean
public CoreV1Api coreV1Api() {
public CoreV1Api coreV1Api(ApiClient apiClient) {
return new CoreV1Api();
}
@Bean
public AppsV1Api appsV1Api() {
public AppsV1Api appsV1Api(ApiClient apiClient) {
return new AppsV1Api();
}
......
spring.main.allow-bean-definition-overriding=true
logging.level.root=INFO
spring.profiles.active=local
osdu.storage.api=https://<service-host>/api/storage/v2
deployment.namespace=osdu-streams
kafka.bootstrapAddress=localhost:9092
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment