Merge remote-tracking branch 'origin/1.1.x'
This commit is contained in:
@@ -49,9 +49,7 @@ public class KubernetesProfileEnvironmentPostProcessor
|
||||
return;
|
||||
}
|
||||
|
||||
final StandardPodUtils podUtils = new StandardPodUtils(
|
||||
new DefaultKubernetesClient());
|
||||
if (podUtils.isInsideKubernetes()) {
|
||||
if (isInsideKubernetes()) {
|
||||
if (hasKubernetesProfile(environment)) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("'kubernetes' already in list of active profiles");
|
||||
@@ -72,6 +70,13 @@ public class KubernetesProfileEnvironmentPostProcessor
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInsideKubernetes() {
|
||||
try (DefaultKubernetesClient client = new DefaultKubernetesClient()) {
|
||||
final StandardPodUtils podUtils = new StandardPodUtils(client);
|
||||
return podUtils.isInsideKubernetes();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasKubernetesProfile(Environment environment) {
|
||||
for (String activeProfile : environment.getActiveProfiles()) {
|
||||
if (KUBERNETES_PROFILE.equalsIgnoreCase(activeProfile)) {
|
||||
|
||||
@@ -3,4 +3,4 @@ org.springframework.cloud.kubernetes.KubernetesAutoConfiguration\
|
||||
|
||||
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||
org.springframework.cloud.kubernetes.profile.KubernetesProfileEnvironmentPostProcessor
|
||||
org.springframework.cloud.kubernetes.profile.KubernetesProfileEnvironmentPostProcessor
|
||||
|
||||
Reference in New Issue
Block a user