Hi, This is a proposal for fixing #18681 A slite change of the way to detect Kubernetes environment.

Let me know what you think.

Comment From: mbhave

Thanks for the PR @medamines1. I don't think that's quite what Dave was suggesting here. I think the order of checks would be

  1. Check for the specific environment variables first: KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT.
  2. If those aren't present, check for the secrets file
  3. If the secret file isn't found, try the current check we have.

Do you want to update the PR to make those changes?

Comment From: medamines1

yes, I'll make the changes and I'll update the PR as soon as possible. thanks for responding @mbhave

Comment From: snicoll

@medamines1 thank you for making your first contribution to Spring Boot. Given the potential side effect when testing an hardcoded file path, I've removed this optimization and also made sure that only environment variables are queried.