Kubernetes and Cloud Native Associate (KCNA) Practice Questions

Kubernetes and Cloud Native Associate (KCNA) exam preparation

Kubernetes and Cloud Native Associate (KCNA) practice questions in English: 180 questions with explanations. The mock exam has 60 questions and 90 minutes.

Kubernetes and Cloud Native Associate (KCNA) free question 5 / 10 · Domain 2: Container Orchestration

You created a NetworkPolicy that denies incoming connections to all Pods in a namespace, and no other NetworkPolicy exists there, but connections from other Pods still succeed. Based on the Kubernetes documentation, which cause is likely?

  1. A NetworkPolicy selects its targets by Service name, so direct Pod connections are not covered
  2. The cluster's network plugin does not implement NetworkPolicy, so the policy is not enforced
  3. An older policy outranks a newer one, because policies are evaluated in the order they were created
  4. A NetworkPolicy takes effect when it is placed as a cluster-wide default policy
Show the answer and explanation

Answer: B

Why this is correct
The Network Policies page says network policies are implemented by the network plugin. To use them, you must be using a networking solution that supports NetworkPolicy, and creating a NetworkPolicy resource without a controller that implements it will have no effect. The API server accepts the object either way, so nothing warns you that traffic is still flowing. The same page rules out the other explanations: network policies do not conflict, they are additive, and order of evaluation does not affect the result. They are namespaced objects that select Pods by labels, and the page lists targeting Services by name and cluster-wide default policies among the things the API cannot express directly.

Why the other options are wrong
"An older policy outranks a newer one, because policies are evaluated in the order they were created" … The page says network policies do not conflict; they are additive, and order of evaluation does not affect the result. No policy outranks another because it was created earlier.
"A NetworkPolicy takes effect when it is placed as a cluster-wide default policy" … The page lists default policies applied to all namespaces or pods as something you cannot do with the NetworkPolicy API alone. A NetworkPolicy is a namespaced resource that applies in its own namespace.
"A NetworkPolicy selects its targets by Service name, so direct Pod connections are not covered" … The page says you cannot target Services by name with a NetworkPolicy, and that you target Pods or namespaces by their labels instead. Pods are selected directly.

The API alone enforces nothing
If a NetworkPolicy seems to do nothing, check that the CNI plugin supports it. The resource is accepted even when no controller enforces it.

Go to the Kubernetes and Cloud Native Associate (KCNA) practice app (10 free questions; purchase unlocks all questions)

See the full practice set