-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[Question]How to specify the service registration endpoint when binding a server to multiple network interfaces? #2902
Comments
|
Using Endpoint() With kratos.New()? If I start multiple servers in kratos.Server(), I have to explicitly specify the endpoint for each server, and I also need to manually convert 0.0.0.0:port to the actual ip:port. Would it be a solution to prioritize using the internal IP for service registration when specifying 0.0.0.0:port? |
The current design of HTTP/gRPC transport is to use private IP as the endpoint value, and it is unclear what exactly you want to do. If you want to control the registered values yourself, you can use the kratos/transport/grpc/server.go Line 221 in db2a565
|
When you listen to port It is recommended to conduct actual testing. If there are any issues, please provide the minimum replication environment or describe the relevant information clearly |
My goal is to prioritize registering the internal IP when configuring 0.0.0.0, but in reality, it doesn't seem to work that way. This issue is difficult to reproduce. Our production services are deployed on physical machines with one network card bound to the internal network and another network card bound to the external network. According to the Extract() method in internal/host/host.go, it seems to iterate through all network cards that meet the conditions and ultimately return the last one, making the actual registered IP unpredictable. Is my understanding correct? Line 89 in 32b1d13
I will also try to provide a minimal replication environment. |
I think Extract() code should include a condition to return early if it is an internal IP. |
It is difficult to coexist with the needs of different users. It is recommended to use endpoint to handle the address registered to the registration center on your own, or consider changing this part to an interface for users to implement on their own |
Thanks a lot for the answer. I can handle this part of the code myself (although I believe it deviates from the original design in terms of the Extract() method). kratos/transport/grpc/server.go Line 119 in 32b1d13
func Endpoint(endpoint *url.URL) ServerOption {
return func(s *Server) {
s.endpoint = endpoint
}
} that allows me to specify the endpoint when defining the server, instead of manually specifying it for each server when creating a new app? I believe this implementation would be more elegant. |
How to listen on 0.0.0.0 for a service while specifying a custom registration endpoint in the service registry? Currently, there doesn't seem to be a direct way.
The text was updated successfully, but these errors were encountered: