-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service discovery via environment variables should be available for all namespaces #87366
Comments
/sig network |
/triage unresolved Comment 🤖 I am a bot run by vllry. 👩🔬 |
There is a lot of overlap/duplication with the discussion in #1768 Injecting all service info from all namespaces is not scalable. Use of DNS largely eliminates the need to know specific IPs of services in other namespaces. /priority awaiting-more-evidence |
@liggitt there is indeed an overlap in the discussion. |
Environment variables for services are already problematic (in that a pod can only have environment variables for the services that existed before it was created). And extending them to cover all namespaces would be a performance problem in large clusters. There is a proposal to deprecate service environment variables altogether.
CoreDNS should serve SRV records which contain the port; if your app doesn't natively support SRV records you could just wrap it in a shell script that manually resolves the record and then passes the port to the app. /close |
@danwinship: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@danwinship what is the suggested way to perform port DNS lookup when there is no appropriate tool (dig/host/nslookup) available in the docker image? |
"add an appropriate tool to the image"? Alternatively, use something like the operator pattern, where both the client and server Pod resources would be created by some other pod, which can then fill in an environment variable in the client Pod's spec pointing to the appropriate port in the server pod. |
@danwinship modifying an image is not really viable for third party applications. As I wrote in the first comment, the alternative would indeed be an init container or a dedicated controller to perform the lookup but it seems like an overkill. |
What would you like to be added:
Environment variables for services in all namespaces within the cluster should be available within a container.
This can be achieved by adding the namespace to the environment variables:
MYAPP_KUBE-SYSTEM_SERVICE_PORT_HTTP=8080
Why is this needed:
Currently service discovery for ports using environment variables is available only for the services within the same namespace.
Using DNS service discovery for ports with SRV records requires either modifying the application to perform DNS SRV lookup or having different process such as an init container or a dedicated controller to perform the lookup which isn't ideal.
The text was updated successfully, but these errors were encountered: