CKA Services and Networking Practice Question
An administrator creates a NetworkPolicy in namespace 'app' with the following YAML. Which statement is true about the policy?
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-all spec: podSelector: {} policyTypes: - Ingress
⚠ Common exam trap
The trap here is that candidates often misinterpret an empty `podSelector: {}` as selecting no pods, when in fact it selects all pods in the namespace, leading them to incorrectly choose option A.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The policy denies all ingress traffic to all pods in the 'app' namespace.
The NetworkPolicy uses an empty `podSelector: {}`, which selects all pods in the namespace, and specifies `policyTypes: [Ingress]` with no ingress rules. By default, Kubernetes NetworkPolicy denies all ingress traffic that is not explicitly allowed, so this policy effectively blocks all incoming traffic to every pod in the 'app' namespace.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The policy denies all ingress traffic to no pods because no podSelector is specified.
Why it's wrong here
In Kubernetes NetworkPolicies, an empty `podSelector` (which defaults to `{}`) selects all pods within the namespace where the policy is created, rather than selecting no pods. Consequently, the policy applies to every pod in the 'app' namespace, making this statement incorrect.
- ✗
The policy denies all egress traffic from all pods in the 'app' namespace.
Why it's wrong here
Since the `policyTypes` list in this NetworkPolicy only contains `Ingress` (or defaults to Ingress), egress traffic remains completely unaffected. Egress rules and restrictions are only enforced when `Egress` is explicitly declared under the `policyTypes` field.
- ✓
The policy denies all ingress traffic to all pods in the 'app' namespace.
Why this is correct
An empty `podSelector` targets all pods in the 'app' namespace, and because the policy defines `Ingress` in its `policyTypes` but contains no allowed ingress rules, it acts as a default-deny policy. This effectively blocks all incoming traffic to every pod in that namespace.
- ✗
The policy allows all ingress traffic to all pods in the 'app' namespace.
Why it's wrong here
Kubernetes NetworkPolicies operate on a default-deny model once a pod is selected by a policy. Because there are no explicit allow rules defined in the ingress section of this policy, all incoming traffic to the selected pods is blocked rather than permitted.
Go deeper
Related to this question
Learn chapter
Installing Kubernetes with kubeadm
Key term
Ingress Resources
Ingress Resources are Kubernetes API objects that manage external access to services inside a cluster, typically HTTP and HTTPS traffic, by defining rules for routing requests based on hostnames and paths.
Key term
Network Policies
A Kubernetes resource that controls how pods communicate with each other and with other network endpoints, acting as a firewall for pod-to-pod traffic.
About these practice questions
Courseiva writes every CKA question from scratch — 726 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.