nerdexam
Linux_Foundation

CKAD · Question #13

Context: Set configuration context: [student@node-1] $ kubectl config use-context nk8s All work on this item should be conducted in the kdsn00201 namespace. All required NetworkPolicy resources are…

This question tests whether you understand how Kubernetes NetworkPolicies are applied to pods via label selectors, and that making a pod subject to an existing policy requires adding the correct labels to the pod - not modifying the policy itself.

Submitted by fatema_kw· May 4, 2026Services and Networking

Question

Context: Set configuration context: [student@node-1] $ kubectl config use-context nk8s All work on this item should be conducted in the kdsn00201 namespace. All required NetworkPolicy resources are already created and ready for use as appropriate. You should not create, modify or delete any network policies whilst completing this item. Task: You have rolled out a new pod to your infrastructure and now you need to allow it to communicate with the web and storage pods but nothing else. Given the running pod kdsn00201-newpod edit it to use a network policy that will allow it to send and receive traffic only to and from the web and storage pods.

Explanation

This question tests whether you understand how Kubernetes NetworkPolicies are applied to pods via label selectors, and that making a pod subject to an existing policy requires adding the correct labels to the pod - not modifying the policy itself.

Approach. NetworkPolicies select the pods they govern using a podSelector that matches pod labels. Since the task explicitly forbids creating or modifying NetworkPolicies, the correct action is to inspect the existing NetworkPolicies in the kdsn00201 namespace (kubectl get networkpolicy -n kdsn00201 -o yaml) to find the policy whose podSelector targets pods allowed to communicate only with web and storage pods. Once you identify the required label(s) from that policy's podSelector, you apply those labels to kdsn00201-newpod using kubectl label pod kdsn00201-newpod -n kdsn00201 <key>=<value> or kubectl edit pod kdsn00201-newpod -n kdsn00201. This causes the existing NetworkPolicy to automatically select the pod, enforcing the desired traffic restriction without touching the policy resource itself.

Concept tested. Kubernetes NetworkPolicy pod selection via label matching - understanding that NetworkPolicies are applied to pods by matching podSelector labels on the pod, and that 'using' a policy means labeling the pod to match the policy's selector, not modifying the policy.

Reference. https://kubernetes.io/docs/concepts/services-networking/network-policies/#networkpolicy-resource

Topics

#NetworkPolicy#Pod Labels#kubectl edit#Networking

Community Discussion

No community discussion yet for this question.

Full CKAD Practice