Bird
0
0

Given this NetworkPolicy snippet, what traffic is allowed?

medium📝 Command Output Q13 of 15
Kubernetes - RBAC and Security
Given this NetworkPolicy snippet, what traffic is allowed?
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-nginx
spec:
  podSelector:
    matchLabels:
      app: nginx
  ingress:
  - from:
    - podSelector:
        matchLabels:
          role: frontend
    ports:
    - protocol: TCP
      port: 80
AOnly pods with label role=frontend can access nginx pods on TCP port 80
BAll pods can access nginx pods on any port
COnly pods with label app=nginx can access frontend pods on port 80
DNo traffic is allowed to nginx pods
Step-by-Step Solution
Solution:
  1. Step 1: Analyze podSelector and ingress rules

    The policy selects pods with label app: nginx and allows ingress only from pods with role: frontend on TCP port 80.
  2. Step 2: Interpret allowed traffic

    Only pods labeled role=frontend can connect to nginx pods on TCP port 80; other traffic is blocked.
  3. Final Answer:

    Only pods with label role=frontend can access nginx pods on TCP port 80 -> Option A
  4. Quick Check:

    Ingress from role=frontend on port 80 = B [OK]
Quick Trick: Ingress from podSelector limits source pods and ports [OK]
Common Mistakes:
  • Assuming all pods can access nginx
  • Confusing source and destination labels
  • Ignoring port restrictions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes