Fabric8ProfileEnvironmentPostProcessor seems to do a bit "too little"
See original GitHub issueSorry for a bad description, I could not come up with a better one.
This is not really a bug, but more of a question to see if it’s OK for me to fix this or not. Currently, Fabric8ProfileEnvironmentPostProcessor
has isInsideKubernetes
defined as:
@Override
protected boolean isInsideKubernetes(Environment environment) {
try (DefaultKubernetesClient client = new DefaultKubernetesClient()) {
final Fabric8PodUtils podUtils = new Fabric8PodUtils(client);
return environment.containsProperty(KUBERNETES_SERVICE_ENV_VAR) || podUtils.isInsideKubernetes();
}
}
it checks for KUBERNETES_SERVICE_ENV_VAR
being present in Environment.
On the other hand podUtils::isInsideKubernetes
, specifically checks if “currently we are inside k8s”. Though, besides the KUBERNETES_SERVICE_ENV_VAR
property, it also checks HOSTNAME
and the presence of both /var/run/secrets/kubernetes.io/serviceaccount/token
and /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
.
IMO, the check environment.containsProperty(KUBERNETES_SERVICE_ENV_VAR)
is too “thin” to prove if we are currently inside kubernetes or not.
This long description is to propose the change to become:
@Override
protected boolean isInsideKubernetes(Environment environment) {
try (DefaultKubernetesClient client = new DefaultKubernetesClient()) {
final Fabric8PodUtils podUtils = new Fabric8PodUtils(client);
return podUtils.isInsideKubernetes();
}
}
The change itself is trivial, but will require some changes for the tests to correctly work.
I will take this and work on it, only if you agree on the change. Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
yes. I will take that in a future PR. It’s a minor thing, indeed
Basically just using
Fabric8PodUtils
instead of defining the variable name ourselves?