Courseiva
Services and NetworkinghardMultiple SelectObjective-mapped

CKA Services and Networking Practice Question

Which TWO of the following are valid ways to isolate a set of pods from all ingress traffic except from monitoring pods?

⚠ Common exam trap

A common mix-up: candidates confuse `namespaceSelector` with `podSelector` and think a namespace-level rule is sufficient to isolate traffic to specific pods, but without a `podSelector` in the ingress rule, all pods in the monitoring namespace are allowed, breaking isolation.

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

Apply a NetworkPolicy with podSelector: matchLabels: { app: myapp }, ingress: [ { from: [ { podSelector: { matchLabels: { role: monitoring } } } ] } ]

It uses a NetworkPolicy with a `podSelector` targeting the protected pods and an `ingress` rule that explicitly allows traffic only from pods with the label `role: monitoring`. This isolates the target pods from all other ingress traffic, as Kubernetes NetworkPolicy defaults to denying ingress when any ingress rule is defined, and only the specified source pods are permitted.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Apply a NetworkPolicy with ingress rule allowing from a specific pod only

    Why it's wrong here

    This alone does not deny other traffic; you need a default deny policy.

  • Apply a NetworkPolicy with empty podSelector and ingress rule allowing all

    Why it's wrong here

    This would allow all ingress to all pods.

  • Apply a NetworkPolicy with podSelector: matchLabels: { app: myapp } and ingress rule with namespaceSelector: { matchLabels: { name: monitoring } }

    Why it's wrong here

    This selects pods in monitoring namespace, not the monitoring pods themselves.

  • Apply a NetworkPolicy with podSelector: matchLabels: { app: myapp }, ingress: [ { from: [ { podSelector: { matchLabels: { role: monitoring } } } ] } ]

    Why this is correct

    This allows ingress from monitoring pods.

  • Apply a NetworkPolicy with podSelector: matchLabels: { app: myapp }, policyTypes: [Ingress], and no ingress rules

    Why this is correct

    This denies all ingress by default.

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 →

How Courseiva writes practice questions · Editorial policy

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.