feature: add kubernetes context in configuration
This commit is contained in:
parent
f1466e88a4
commit
0c4e87d1ab
@ -11,7 +11,7 @@ trim_trailing_whitespace = true
|
|||||||
tab_width = 2
|
tab_width = 2
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
[*.java]
|
[{*.java,*.js}]
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
ij_continuation_indent_size = 4
|
ij_continuation_indent_size = 4
|
||||||
|
|
||||||
|
@ -8,6 +8,6 @@ public record BackofficeProperties(String apiPrefix, Kubernetes kubernetes) {
|
|||||||
public record Kubernetes(Api api) {
|
public record Kubernetes(Api api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Api(String kubeconfig) {
|
public record Api(String kubeconfig, String context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ public class KubernetesClientConfiguration {
|
|||||||
@Profile("dev")
|
@Profile("dev")
|
||||||
public ApiClient devClient(BackofficeProperties backofficeProperties) throws IOException {
|
public ApiClient devClient(BackofficeProperties backofficeProperties) throws IOException {
|
||||||
String kubeConfigPath = backofficeProperties.kubernetes().api().kubeconfig();
|
String kubeConfigPath = backofficeProperties.kubernetes().api().kubeconfig();
|
||||||
|
String context = backofficeProperties.kubernetes().api().context();
|
||||||
File kubeConfigFile = new File(kubeConfigPath);
|
File kubeConfigFile = new File(kubeConfigPath);
|
||||||
try (BufferedReader kubeConfigReader =
|
try (BufferedReader kubeConfigReader =
|
||||||
new BufferedReader(
|
new BufferedReader(
|
||||||
@ -38,6 +39,7 @@ public class KubernetesClientConfiguration {
|
|||||||
|
|
||||||
KubeConfig kubeConfig = KubeConfig.loadKubeConfig(kubeConfigReader);
|
KubeConfig kubeConfig = KubeConfig.loadKubeConfig(kubeConfigReader);
|
||||||
kubeConfig.setFile(kubeConfigFile);
|
kubeConfig.setFile(kubeConfigFile);
|
||||||
|
kubeConfig.setContext(context);
|
||||||
|
|
||||||
return ClientBuilder.kubeconfig(kubeConfig).setPingInterval(Duration.ofSeconds(2)).build();
|
return ClientBuilder.kubeconfig(kubeConfig).setPingInterval(Duration.ofSeconds(2)).build();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user