CKA Services and Networking Practice Question
You apply the following NetworkPolicy to namespace 'ns1': apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-ingress spec: podSelector: {} policyTypes: - Ingress ingress: [] What effect does this policy have?
⚠ Common exam trap
The trap here is that candidates often misinterpret an empty `ingress: []` as 'no restrictions' (i.e., allow all), when in fact Kubernetes NetworkPolicy semantics define an empty rule list as denying all traffic of that type, which is a common point of confusion in the CKA exam.
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
✓
Denies all ingress traffic to all pods in namespace ns1.
This NetworkPolicy selects all pods in namespace 'ns1' (via empty `podSelector: {}`), specifies `policyTypes: [Ingress]`, and defines an empty `ingress: []` rule list. In Kubernetes, an empty `ingress: []` explicitly denies all ingress traffic because no allow rules are present, overriding the default allow-all behavior. Therefore, all ingress traffic to any pod in ns1 is denied.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Denies all egress traffic as well.
Why it's wrong here
The policyTypes field in this NetworkPolicy only includes Ingress, not Egress. Since no egress rules are defined and egress is not listed in policyTypes, the policy has no effect on outgoing traffic. Therefore, pods selected by the policy can still initiate outbound connections; egress traffic remains unrestricted.
- ✗
Allows ingress traffic only from pods in the same namespace.
Why it's wrong here
An empty ingress rules list is not a permissive rule that auto-allows same-namespace peers. NetworkPolicy defines an allowlist; with no podSelector or namespaceSelector specified inside the ingress array, there are no allowed sources. Consequently, even traffic from pods sharing the namespace is dropped because none of those sources match a rule.
- ✓
Denies all ingress traffic to all pods in namespace ns1.
Why this is correct
This policy selects all pods in ns1 (or a specific subset, depending on podSelector) and explicitly lists Ingress in policyTypes while providing an empty ingress list. Under Kubernetes NetworkPolicy semantics, an empty rules list means no incoming connections are permitted, so every pod matched by the selector is denied all ingress traffic. This effectively implements a deny-all-ingress rule for the namespace.
- ✗
Allows all ingress traffic because no explicit deny rules are defined.
Why it's wrong here
NetworkPolicy does not rely on explicit deny rules; it is an allowlist mechanism. If a policy applies to a pod and its ingress array is empty, the default behavior is to deny all ingress traffic, because there are no allow rules to match. This is the opposite of "no explicit deny means allow" — in Kubernetes, no allow rule means deny.
Go deeper
Related to this question
Learn chapter
Kubernetes Architecture Overview
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.
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.
About these practice questions
Courseiva writes every CKA question from scratch — 302 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.