Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to a service in another pod in same namespace without using namespace in URL

Tags:

kubernetes

How to access a service from another pod in same namespace without using namespace name in URL?

Can't use this as it is using namespace name in url. <service-name>.<namespace>.svc.cluster.local

Reason: namespace names are dynamic in my setup and not in my control.

like image 200
Azodious Avatar asked Sep 20 '25 04:09

Azodious


1 Answers

You can just directly use the other Service name as a host name if you know it's in the same namespace as your Pod.

http://<service-name>/path

DNS for Services and Pods documents that both svc.cluster.local and <namespace>.svc.cluster.local are added to the default DNS search path (in the container's /etc/resolv.conf file), which makes this work.

like image 123
David Maze Avatar answered Sep 22 '25 21:09

David Maze