Bird
0
0

You have a multi-namespace Kubernetes cluster with services named api in namespaces dev and prod. How can a pod in dev namespace connect to the api service in prod namespace using DNS?

hard📝 Best Practice Q15 of 15
Kubernetes - Services
You have a multi-namespace Kubernetes cluster with services named api in namespaces dev and prod. How can a pod in dev namespace connect to the api service in prod namespace using DNS?
AUse the full DNS name <code>api.prod.svc.cluster.local</code>
BUse just <code>api</code> since it resolves across namespaces
CUse <code>api.dev.svc.cluster.local</code> and specify namespace in config
DUse the IP address of the <code>prod</code> service directly
Step-by-Step Solution
Solution:
  1. Step 1: Understand cross-namespace DNS resolution

    Within a namespace, service names resolve locally; cross-namespace requires full DNS name.
  2. Step 2: Apply full DNS name for cross-namespace access

    To reach api in prod from dev, use api.prod.svc.cluster.local.
  3. Final Answer:

    Use the full DNS name api.prod.svc.cluster.local -> Option A
  4. Quick Check:

    Cross-namespace = full DNS name [OK]
Quick Trick: Cross-namespace access needs full DNS name service.namespace.svc.cluster.local [OK]
Common Mistakes:
  • Assuming service name alone resolves across namespaces
  • Using wrong namespace in DNS name
  • Relying on IP addresses which can change

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes