gotchakubernetesModeratepending
Gotcha: Kubernetes Service DNS not resolving across namespaces
Viewed 0 times
DNSnamespaceFQDNservicecross-namespacecluster.local
Error Messages
Problem
A Kubernetes Service can be reached by name within its namespace but fails to resolve from another namespace.
Solution
Use fully qualified service names for cross-namespace access:
# Within same namespace:
curl http://my-service:8080
# Cross-namespace (FQDN):
curl http://my-service.other-namespace.svc.cluster.local:8080
# Short form (usually works):
curl http://my-service.other-namespace:8080
# Format: <service>.<namespace>.svc.cluster.local
# Check DNS resolution:
kubectl run -it --rm debug --image=busybox -- nslookup my-service.other-namespace
# Common issues:
kubectl get endpoints my-service -n other-namespace
kubectl get pods -n kube-system -l k8s-app=kube-dns
# Headless service (no ClusterIP):
# Returns pod IPs directly, DNS still works the same way
# Within same namespace:
curl http://my-service:8080
# Cross-namespace (FQDN):
curl http://my-service.other-namespace.svc.cluster.local:8080
# Short form (usually works):
curl http://my-service.other-namespace:8080
# Format: <service>.<namespace>.svc.cluster.local
# Check DNS resolution:
kubectl run -it --rm debug --image=busybox -- nslookup my-service.other-namespace
# Common issues:
- NetworkPolicy blocking cross-namespace traffic
- Service type ClusterIP not accessible outside cluster
- Service has no endpoints (no matching pods)
kubectl get endpoints my-service -n other-namespace
- CoreDNS not running:
kubectl get pods -n kube-system -l k8s-app=kube-dns
# Headless service (no ClusterIP):
# Returns pod IPs directly, DNS still works the same way
Revisions (0)
No revisions yet.