Courseiva

CKS Monitoring, Logging and Runtime Security Practice Question

A compromised pod is making unexpected outbound connections. You want to isolate the pod by blocking all egress traffic while keeping it running for forensic analysis. Which action is correct?

⚠ Common exam trap

CKS often tests whether candidates understand that NetworkPolicy is additive and that an empty egress rule set means deny-all; a common mistake is thinking you must delete the pod or that /etc/hosts changes provide 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 that selects the pod and has no egress rules, effectively blocking all outbound traffic

Applying a NetworkPolicy that selects the pod with no egress rules blocks all outbound traffic while leaving the pod running, which is exactly what forensic isolation requires. In Kubernetes, once a pod is selected by a NetworkPolicy with an egress policy type, only explicitly allowed egress is permitted — an empty egress rule set means deny all. This preserves the pod's state and memory for analysis.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Use kubectl exec to kill the outbound processes inside the container

    Why it's wrong here

    Using kubectl exec to manually kill processes is an anti-pattern for incident response: it mutates the live container, may trigger restart loops from supervisors or Kubernetes's restart policy, and does not block the vulnerable pod's ability to initiate new connections. Network connections are established at the kernel/socket layer, so process termination is not guaranteed to close existing TCP sessions or prevent the container from being re-executed. It also consumes valuable time and requires exec privileges, whereas a NetworkPolicy provides deterministic, declarative isolation without altering container state.

  • ✓

    Apply a NetworkPolicy that selects the pod and has no egress rules, effectively blocking all outbound traffic

    Why this is correct

    A NetworkPolicy that selects the compromised pod and specifies an empty egress rule list (e.g., `egress: []`) enforces a default-deny model for all outbound traffic. Because NetworkPolicy rules are additive—only traffic explicitly allowed by a matching rule passes—an empty list allows nothing, effectively containing the pod while preserving its state for forensics. For this to work, the cluster must run a CNI that implements NetworkPolicy, such as Calico, Cilium, or Weave Net. Alternatively, setting `policyTypes: [Egress]` with no egress rules achieves the same isolation.

  • ✗

    Modify the pod's /etc/hosts to block external IPs

    Why it's wrong here

    Editing `/etc/hosts` is a weak containment measure because it only influences local DNS resolution—processes that connect to IP addresses directly or use their own resolvers will bypass it entirely. The file is stored on the container's writable layer, so any change is ephemeral and can be overwritten by the kubelet, image pulls, or a container restart. Moreover, this approach requires `kubectl exec`, altering the forensic integrity of the pod and relying on non-Kubernetes mechanisms, whereas NetworkPolicy is enforced at the CNI dataplane before packets leave the pod.

  • ✗

    Delete the pod and recreate it with a restrictive NetworkPolicy

    Why it's wrong here

    Deleting and recreating the pod is counterproductive during incident response because it destroys the live memory, filesystem, and network connection evidence needed to analyze the compromise. The new pod will typically receive a different IP address, and any restrictive policy must be re-applied to the new pod's labels; meanwhile, the attacker may have already moved laterally. Even if the policy is recreated, the original compromised state is lost forever. In contrast, applying a NetworkPolicy to the existing pod contains the threat without losing evidence and can be reversed after investigation.

Visual reference

Source Router + ACL permit 10.0.0.0/8 deny any Server 10.0.0.5 ✓ 192.168.1.1 ✗ dropped ACLs evaluate top-down; first match wins — implicit deny all at end

About these practice questions

One of 845 original CKS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CNCF exam blueprint

This CKS 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 CKS exam.