Two namespaces need to call each other's services but you must keep them isolated otherwise. How?
IntermediateScenarioServices, Ingress and DNS
Answer
Situation read → team-a needs the API in team-b.
What I'd do →
- Use the FQDN
api.team-b.svc.cluster.local - Add a NetworkPolicy in team-b that allows ingress from namespaces with label
team: ausingnamespaceSelector - Ensure the default deny stays in place
- Allow DNS egress
- Test using a debug pod in team-a
Why → DNS is global across the cluster, so isolation must be enforced by policy, not naming.
Interview tip → Mention that namespace selectors rely on the automatic label kubernetes.io/metadata.name.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?Intermediate