As we know, kubernetes supports 2 primary modes of finding a Service - environment variables and DNS, could we disable the first way and only choose the DNS way?
As shown in this PR, this feature will land with Kubernetes 1.13. From the PR (as Docs are not available yet) I expect it to be the field enableServiceLinks
in the pod spec with true as default.
Edit: As it has been a while and the PR finally landed. The enableServiceLinks
was added as optional Boolean to the Kubernetes PodSpec.
For the record: using DNS to discover service endpoints is the recommended approach and the docker link
behavior, from where the environment variables originate, is long deprecated
Per kubernetes v1.8 source, it's impossible to disable services discovery with environment variables.
Only service meet either condition is exposed by envVars.
kubernetes
service in the default
namespace;Even though, these environment variables can be overwritten by env
and envFrom
defined in pod template.
I'm wondering what's your scenario, maybe we can figure out some workaround.