Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Data Flow
Real Time
Streams
Stream Admin Service
Commits
889d5e03
Commit
889d5e03
authored
Nov 16, 2021
by
Stephen Nimmo
Browse files
Updated KubernetesAdminConfiguration to support multiple active profiles
parent
af275f94
Pipeline
#77442
failed with stage
in 1 minute and 13 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/main/java/org/opengroup/osdu/streaming/util/KubernetesAdminConfiguration.java
View file @
889d5e03
...
...
@@ -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
();
}
...
...
src/test/resources/application.properties
View file @
889d5e03
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment