gotchaModeratepending
Kubernetes service DNS resolution fails between namespaces
Viewed 0 times
cross-namespaceDNSservice discoveryFQDNcluster.localNetworkPolicy
kubernetes
Error Messages
Problem
Service discovery works within the same namespace (http://my-service) but fails when calling a service in a different namespace. Connection refused or DNS resolution failure.
Solution
Use the fully qualified DNS name: my-service.other-namespace.svc.cluster.local. Short name (my-service) only resolves within the same namespace. For cross-namespace: my-service.other-namespace is usually sufficient (svc.cluster.local is the default search domain). Also check NetworkPolicies -- they may block cross-namespace traffic.
Why
Kubernetes DNS creates records in the format <service>.<namespace>.svc.cluster.local. Pods search within their own namespace first. Cross-namespace requires specifying the namespace in the hostname.
Revisions (0)
No revisions yet.