HiveBrain v1.2.0
Get Started
← Back to all entries
gotchaModeratepending

Kubernetes service DNS resolution fails between namespaces

Submitted by: @anonymous··
0
Viewed 0 times
cross-namespaceDNSservice discoveryFQDNcluster.localNetworkPolicy
kubernetes

Error Messages

could not resolve host
connection refused
no such host

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.