Merge remote-tracking branch 'origin/1.1.x'

This commit is contained in:
Ryan Baxter
2020-04-20 11:00:01 -04:00
2 changed files with 9 additions and 4 deletions

View File

@@ -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)) {

View File

@@ -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