Bird
0
0

You want to restrict pods to only receive traffic from pods in the same namespace and send traffic only to a specific external IP range 192.168.1.0/24. Which NetworkPolicy configuration achieves this?

hard📝 Best Practice Q15 of 15
Kubernetes - Networking
You want to restrict pods to only receive traffic from pods in the same namespace and send traffic only to a specific external IP range 192.168.1.0/24. Which NetworkPolicy configuration achieves this?
Aingress: - from: - podSelector: {} egress: - from: - ipBlock: cidr: 192.168.1.0/24
Bingress: - from: - namespaceSelector: {} egress: - to: - ipBlock: cidr: 10.0.0.0/24
Cingress: - from: - podSelector: {} egress: - to: - ipBlock: cidr: 192.168.1.0/24
Dingress: - to: - podSelector: {} egress: - to: - ipBlock: cidr: 192.168.1.0/24
Step-by-Step Solution
Solution:
  1. Step 1: Configure ingress to allow same-namespace pods

    Using podSelector: {} allows traffic from all pods in the same namespace.
  2. Step 2: Configure egress to allow only specific external IP range

    Egress uses to with ipBlock for 192.168.1.0/24 to restrict outgoing traffic.
  3. Final Answer:

    ingress: - from: - podSelector: {} egress: - to: - ipBlock: cidr: 192.168.1.0/24 -> Option C
  4. Quick Check:

    Ingress 'from' podSelector + Egress 'to' ipBlock [OK]
Quick Trick: Ingress uses 'from' podSelector; egress uses 'to' ipBlock [OK]
Common Mistakes:
  • Using 'from' in egress rules
  • Using namespaceSelector instead of podSelector for ingress
  • Mixing 'to' and 'from' keywords incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes