You must restrict an app so that only the frontend can call it. Services alone do not do that. What do you add?
AdvancedScenarioServices, Ingress and DNS
Answer
Situation read → Any pod in the cluster can call the backend today.
What I'd do →
- Confirm the CNI enforces NetworkPolicy (Calico, Cilium, or VPC CNI network policy mode)
- Create a default-deny ingress policy in the namespace
- Add an allow policy selecting backend pods and the frontend pod labels (plus namespaceSelector if cross-namespace)
- Allow DNS egress to kube-dns if you also restrict egress
- Test with
kubectl execfrom allowed and denied pods
Why → Services only provide discovery and load balancing. Isolation requires NetworkPolicy enforced by the CNI.
Interview tip → Mention that NetworkPolicy objects are silently ignored if the CNI does not implement them.
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