Question 1
Topic: Cluster Setup
Skill tested: Configure namespace-scoped NetworkPolicy ingress and egress restrictions for application pods.
A payment service runs in namespace `payments` and listens on TCP port 8443. It must accept connections only from pods carrying `role=frontend` in namespace `web`, and it must initiate connections only to pods labelled `role=ledger` in its own namespace on TCP 9443. The cluster's CNI enforces Kubernetes NetworkPolicy, and the payment pods have no other required network dependencies. Which policy correctly enforces both restrictions?
A NetworkPolicy selects the pods whose traffic it governs. Selecting payment pods and declaring both `Ingress` and `Egress` makes them isolated in both directions; the specified peer selectors and ports then allow only the required flows. A namespace selector and pod selector in the same peer entry are conjunctive, so both the frontend label and `web` namespace are required. An ingress-only policy does not restrict egress, selecting frontend pods governs the wrong workloads, and broad namespace-only rules permit more peers than the scenario allows.