DCA · Question #65
The Kubernetes yaml shown below describes a networkPolicy. Will the networkPolicy BLOCK this traffic? Solution: a request issued from a pod bearing the tier: backend label, to a pod bearing the…
The correct answer is B. No. The traffic from a pod labeled tier: backend to a pod labeled tier: frontend will not be blocked by the NetworkPolicy.
Question
The Kubernetes yaml shown below describes a networkPolicy. Will the networkPolicy BLOCK this traffic? Solution: a request issued from a pod bearing the tier: backend label, to a pod bearing the tier:
frontend label
Options
- AYes
- BNo
How the community answered
(25 responses)- A20% (5)
- B80% (20)
Why each option
The traffic from a pod labeled `tier: backend` to a pod labeled `tier: frontend` will not be blocked by the NetworkPolicy.
If the traffic were blocked, the NetworkPolicy would need to select the destination pod and lack an `ingress` rule permitting traffic from `tier: backend`, or select the source pod and lack an `egress` rule permitting traffic to `tier: frontend`.
Given that the traffic is not blocked, the NetworkPolicy either does not select the destination `tier: frontend` pod, meaning all ingress traffic to it is allowed by default. Alternatively, if a policy does select the `tier: frontend` pod, its `ingress` rules must explicitly permit traffic from pods with the `tier: backend` label, or the source pod's `egress` rules allow traffic to `tier: frontend`.
Concept tested: Kubernetes NetworkPolicy ingress/egress rules
Source: https://kubernetes.io/docs/concepts/services-networking/network-policies/#the-networkpolicy-resource
Topics
Community Discussion
No community discussion yet for this question.