Ingress uses 'from' to allow incoming traffic [OK]
Hint: 'ingress' with 'from' allows incoming traffic sources [OK]
Common Mistakes:
Using 'to' instead of 'from' in ingress
Confusing ingress with egress syntax
Misplacing namespaceSelector under egress
3. Given this NetworkPolicy snippet, what traffic is allowed?
egress:
- to:
- ipBlock:
cidr: 10.0.0.0/24
except:
- 10.0.0.5/32
medium
A. All outgoing traffic to 10.0.0.0/24 except 10.0.0.5
B. All incoming traffic from 10.0.0.0/24 except 10.0.0.5
C. All outgoing traffic to 10.0.0.5 only
D. All incoming traffic from 10.0.0.5 only
Solution
Step 1: Analyze egress rule with ipBlock
The rule allows outgoing traffic to IPs in 10.0.0.0/24 except 10.0.0.5.
Step 2: Confirm direction and exceptions
Egress means outgoing traffic; 'except' excludes 10.0.0.5 from allowed IPs.
Final Answer:
All outgoing traffic to 10.0.0.0/24 except 10.0.0.5 -> Option A
Quick Check:
Egress with ipBlock except excludes IPs [OK]
Hint: Egress 'to' with ipBlock allows excepted IPs blocked [OK]
Common Mistakes:
Confusing ingress with egress direction
Misreading 'except' as allowed IP
Mixing incoming and outgoing traffic
4. You wrote this NetworkPolicy egress rule but pods still cannot reach external IPs:
egress:
- from:
- ipBlock:
cidr: 0.0.0.0/0
What is the error?
medium
A. NetworkPolicy must not have egress rules
B. CIDR 0.0.0.0/0 is invalid
C. Missing 'ports' section
D. Egress rules use 'to', not 'from'
Solution
Step 1: Check egress rule syntax
Egress rules specify destinations with 'to', not 'from'. Using 'from' is invalid here.
Step 2: Understand correct usage
Correct egress syntax uses 'to' to define allowed outgoing IP blocks.
Final Answer:
Egress rules use 'to', not 'from' -> Option D
Quick Check:
Egress uses 'to' for destinations [OK]
Hint: Egress rules always use 'to' keyword [OK]
Common Mistakes:
Using 'from' in egress rules
Assuming CIDR 0.0.0.0/0 is invalid
Thinking ports are always required
5. 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?