-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
use a NodePort service as ExternalName in another service type ExternalName for configuring default-backend #12158
Comments
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
/remove-kind bug /close |
@longwuyuan: 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-sigs/prow repository. |
/reopen |
@chessman: Reopened 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-sigs/prow repository. |
/retitle use a NodePort service as ExternalName in another service type ExternalName for configuring default-backend |
@chessman thanks for your comments. Using data to discuss helps everyone get on the same page.
|
@chessman please discuss the issue here and not in the PR I am copy/pasting the docs for the annotation default-backend You can see clearly that we support another service in the same namespace. There is no reference of supporting a service from another namespace as default-backend. So this is not a bug. And there are no resources or interests to start supporting service from another namespace as default-backend. You do have the option to set a global custom-backend https://kubernetes.github.io/ingress-nginx/examples/customization/custom-errors/ |
@longwuyuan
Yes, I'm aware of it. I did it just to create a simple reproduction. My use case is more complex, I need to set default backend in different namespaces to one in-cluster service.
This is not ideal solution in my case. I need to handle only "no active endpoints" with the service, it can be done only with default backend set in annotations. With global backend I cannot distinguish "no active endpoints" from 503 returned by a service. |
@chessman I completely agree with you on all your latest comments above. I also wish that this can be solved for you and that your requirements for using a service from another namespace are met. But it seems my earlier comments were not precise or informative. So I will try to rephrase my earlier comments.
|
@longwuyuan BTW, we can consider the opposite case - ExternalName service in Ingress and ClusterIP in default backend. Due to the fact that currently a wrong service is used for default backend, it will treat the ClusterIP service as an external service. I'm not sure that it works correctly and probably it also entails some security risks. |
@longwuyuan Also, probably it works without my change if both Ingress and default backend are external services. If you think that this is a security issue, then you need to explicitly validate default backend. But again, I don't understand why it is ok in Ingress and not ok in default backend. |
Practically, you can try to create default-backend in each namespace where you use a ingress resource. It means deploying same workload many times. But default-backend can be very very light. Our example custom-backend is very very small.
|
By "wrong" here I meant how default backend is created: |
I am not a developer so I could be talking crap here. |
you want to "SET" a service because the ExternalName destination is not a EndPoint obtained from the EndpointSlice that the controller looks at ? |
The endpoints are correct, they are returned from here https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/controller/endpointslices.go#L55-L77 |
And if the name in the endpoint is a name that is internal to the cluster and only resolved by CoreDNS in the cluster, then the lua_balancer is not using CoreDNS as nameserver but some other nameserver outside the cluster ? |
Sorry, this I don't get. I tested after applying the patch, lua_balancer can resolve the internal name. Without the patch, lua_balancer is not trying to resolve. |
then back to original question, why do you need to "SET" service ? The error messages you posted are ipv6 related or the unlikely ipv4 address 0.0.0.1 ? If you "SET" service, then do you suddenly get ipv6 or a different address as compared to 0.0.0.1 ? |
In any case, the basic idea of connecting to another namespace is a non starter. The project will not even discuss allowing cross-namespace, as it is literally a CVE. But all these are my opinions, I have no more input. Please wait for other comments. |
If I don't set the service, lua code passes the address "as is" to https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.lua, which does not expect FQDN, so it tries to interpret it as IPv6. 0.0.0.1 comes from there as well. If I set the service, lua wrapper resolves the address before passing it to |
Similar questions here #12173 |
/close Closing this because this topic i sbeing discussed in #12173 |
@longwuyuan: 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-sigs/prow repository. |
What happened:
I'm trying to use an ExternalName service as a default backend for an Ingress to handle situation when the deployment has no active endpoints. I get 504 Gateway Time-out error. In controller logs:
What you expected to happen:
The request should be passed to the default backend service. It should not treat the external name as an IPv6 address. AFAIK, it works when an external name service is used in Ingress. Why is default backend handled differently?
NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):
v1.11.2
Kubernetes version (use
kubectl version
):v1.31.0
Environment:
Initially I experienced this in EKS, then I reproduced it in Minikube.
Cloud provider or hardware configuration: Minikube v1.34.0
OS (e.g. from /etc/os-release): Ubuntu 24.04
Kernel (e.g.
uname -a
): 6.8.0-45How was the ingress-nginx-controller installed:
minikube addons enable ingress
How to reproduce this issue:
Install minikube
minikube start
Install the ingress controller
minikube addons enable ingress
Install hello-app with 0 replicas
Install echo server
Create ExternalName service that points to echo service
Create an ingress for hello-app with echo service external name as default backend
Send a request
The text was updated successfully, but these errors were encountered: