I'm trying to figure out how to connect my services within Kubernetes. The setup I have is: when a user types in 'mydomain.com', Ingress routes the request to Service A, which then communicates with Pod A. From there, Pod A needs to call Service B, which then calls Pod B. However, when Pod B tries to return to the original URL 'mydomain.com', I want it to go back to Service A or Pod A, but not the Ingress directly. I attempted to create a service using the URL 'mydomain.com', but it doesn't allow dots. How can I achieve this routing within Kubernetes?
4 Answers
Another approach is to utilize the internal cluster DNS directly. Avoid any references to the public domain inside your cluster—it'll save you a lot of headaches!
When Pod B needs to call Pod A, you'll want to use the Kubernetes DNS name for Service A instead of the public domain. The main thing here is to ensure you’re working within the cluster's networking. Calling the public domain just won’t work from the cluster.
And don’t forget about the internal DNS. That’ll help with routing properly between your services.
Try adding a DNS rule in CoreDNS to manage your internal calls more effectively. This can help with services trying to call each other.
Instead of public domains, always reference the Kubernetes services to avoid routing problems. If you have a bit of control over your application calls, that would simplify things a lot!
For sure! Using cluster DNS is key here.
You might also want to check out adding a rewrite rule in CoreDNS if you want to tweak DNS resolution.

Exactly! Use the format 'SERVICENAME.NAMESPACE.svc.cluster.local' to reach the services without any issues.