Network Policy: KCSA practice questions
A NetworkPolicy controls traffic at the IP address and port level (OSI layers 3 and 4) for TCP, UDP and SCTP, between Pods and between Pods and the outside world. It is an application-centric object in the networking.k8s.io API group.
By Ibrahim Yesilay · Published · Updated
Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.
What Network Policy covers in KCSA
A NetworkPolicy controls traffic at the IP address and port level (OSI layers 3 and 4) for TCP, UDP and SCTP, between Pods and between Pods and the outside world. It is an application-centric object in the networking.k8s.io API group. The peers a Pod may talk to are expressed in three ways: other Pods chosen by label, namespaces chosen by label, and IP blocks written as CIDR ranges. Labels are therefore the backbone of network segmentation; a policy can only target what it can select, which is why commands such as kubectl label pod matter here.
Without any policy, Pods are non-isolated: all inbound and all outbound connections are allowed. A Pod becomes isolated for ingress when at least one NetworkPolicy selects it and lists Ingress in its policyTypes, and isolated for egress when a selecting policy lists Egress. Once isolated in a direction, only connections explicitly allowed by some applicable policy are permitted, and reply traffic for those connections is allowed implicitly. Policies never conflict: they are additive, so the allowed set is the union of all applicable rules and evaluation order does not matter. For a connection between two Pods to succeed, the egress side of the source and the ingress side of the destination must both allow it.
The spec has a few fields to know precisely. podSelector chooses the Pods the policy applies to, and an empty podSelector selects every Pod in the namespace. policyTypes lists Ingress, Egress or both; if it is omitted, Ingress is always assumed and Egress is added only when the policy has egress rules. ingress rules use from, egress rules use to, and both combine peers with ports. Inside a peer, namespaceSelector alone admits all Pods in matching namespaces, while namespaceSelector and podSelector in the same element admit only matching Pods in matching namespaces, so YAML indentation changes the meaning. A default deny for egress is a policy with podSelector {} and policyTypes Egress and no egress rules; note that it also blocks DNS unless another policy allows traffic to the cluster DNS service. Leaving egress unrestricted means a compromised Pod can open connections to any destination.
Enforcement depends on the network plugin. Creating a NetworkPolicy in a cluster whose plugin does not implement it has no effect at all, which is the usual reason a policy seems to be ignored. The Kubernetes documentation lists Antrea, Calico, Cilium and Kube-router as providers. The API also has deliberate limits: it cannot handle TLS, cannot target Services by name, cannot log blocked connections and has no explicit deny rule. The documentation points to service meshes, ingress controllers and operating system components for those needs.
Key points
- Pods are non-isolated by default: all ingress and egress is allowed until a policy selects them.
- An empty podSelector ({}) selects every Pod in the policy’s namespace.
- If policyTypes is omitted, Ingress is always set and Egress only when egress rules exist.
- A NetworkPolicy has no effect unless the network plugin enforces it.
Three sample questions
18 KCSA questions on Network Policy, 18 with explanations. How practice works
Question 1
- A.By default, they block all traffic between pods.
- B.They use iptables rules (via the CNI plugin) to control pod communication.
- C.They are enforced by the kube-scheduler.
- D.They manage access to the Kubernetes API.
- E.They control storage access for pods.
Correct answer: B
Sources: Kubernetes Network Policies (Official Documentation), Kubernetes Security Best Practices (Mirantis)
Question 2
- A.Network Policies are enabled by default in all clusters
- B.The installed CNI plugin does not support Network Policies
- C.The Network Policy YAML contains syntax errors
- D.The Kubernetes API server is unavailable
- E.Network Policies only apply to traffic from outside the cluster
Correct answer: B
Sources: Kubernetes Official Documentation - Network Policies, CNI Plugins and Network Policy Support
Question 3
Select all that apply.
- A.Flannel
- B.Calico
- C.Weave Net
- D.AWS VPC CNI
- E.Cilium
Correct answers: B, C, D, E
Sources: AWS Announcement on VPC CNI Network Policy Support, AWS EKS Documentation on Network Policy Configuration, Kubernetes Documentation on Network Policies
Practice this topic
Focus mode keeps every question on Network Policy until you leave it. 10 free guest answers, then a free account; no credit card.
Or open KCSA practice across all topics.
Sources
The explanation above was checked against these official documents.
- Kubernetes docs: Network Policies (checked 2026-10-23)
- Kubernetes docs: Declare Network Policy (checked 2026-10-23)
- Kubernetes docs: Install a Network Policy Provider (checked 2026-10-23)
Frequently asked questions
Does a default-deny egress policy break DNS?
Yes. It blocks all egress from the selected Pods, including DNS lookups, so workloads that need name resolution need an additional policy that allows egress to the cluster DNS service.