Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Network Engineer practice bank has an additional 2,437 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You manage a Google Kubernetes Engine (GKE) cluster configured with GKE Dataplane V2 and Workload Identity Federation for GKE. You are deploying a payments-api microservice (app: payments-api) in the payments namespace and must create a NetworkPolicy in the payments namespace that enforces the following requirements:
8443 only from Pods labeled app: checkout-web running inside the frontend namespace (kubernetes.io/metadata.name: frontend).kube-system Pods and outgoing authentication requests to the GKE metadata server.payments-api Pods.How should you configure the NetworkPolicy manifest?
policyTypes to ["Ingress", "Egress"] targeting app: payments-api, define a single ingress.from list item combining namespaceSelector for frontend and podSelector for app: checkout-web with protocol: TCP and no port specified, and allow egress to kube-system on TCP/UDP port 53 and 169.254.169.252/32 on TCP ports 987 and 988.This configuration combines namespaceSelector and podSelector properly for ingress, but omits the port field while specifying protocol: TCP and targets the legacy GKE Dataplane V1 metadata server IP and ports in the egress policy.
NetworkPolicy port entries that specify a protocol with an empty port field. Furthermore, omitting port 8443 fails to restrict ingress exclusively to the required application port.169.254.169.252/32 on ports 987 and 988 blocks Workload Identity Federation for GKE in Dataplane V2 clusters, because Dataplane V2 routes metadata requests to 169.254.169.254/32 on ports 80 and 8080.protocol (TCP, UDP, or SCTP) is declared inside a ports block on GKE Dataplane V2, a specific port number or named port must also be provided.169.254.169.252/32 (ports 987 and 988) applies only to legacy clusters not using Dataplane V2 (GKE versions 1.21.0-gke.1000 and later).The cluster were running Calico (Dataplane V1) instead of GKE Dataplane V2 on GKE 1.21.0-gke.1000 or later, and the requirement allowed all TCP ports rather than restricting ingress specifically to port 8443.
policyTypes to ["Ingress", "Egress"] targeting app: payments-api, define two separate list items under ingress.from (one with namespaceSelector for frontend and one with podSelector for app: checkout-web) on TCP port 8443, and allow egress to kube-system on TCP/UDP port 53 and 169.254.169.254/32 on TCP ports 80 and 8080.This configuration applies a NetworkPolicy to the payments-api Pods using both Ingress and Egress enforcement while splitting the namespaceSelector and podSelector into two distinct YAML list items under the ingress.from array.
NetworkPolicy specifications, separate list items under from are evaluated using logical OR semantics rather than logical AND. Defining two separate entries permits TCP port 8443 traffic from any Pod in the frontend namespace regardless of its labels, as well as any Pod labeled app: checkout-web located inside the payments namespace.frontend namespace could reach the payments-api endpoint directly.-) inside ingress.from or egress.to represents an independent peer rule evaluated additively.namespaceSelector and podSelector within the same list item (without a hyphen before podSelector) creates a logical AND condition.podSelector without a namespaceSelector defaults to matching Pods only within the policy's own namespace (payments).169.254.169.254/32) are accurate, the ingress peer logic is flawed.You intentionally wanted to allow payments-api to accept traffic from every Pod in the frontend namespace in addition to app: checkout-web Pods running in the payments namespace.
policyTypes to ["Ingress", "Egress"] targeting app: payments-api, define a single ingress.from list item combining both namespaceSelector for frontend and podSelector for app: checkout-web on TCP port 8443, and allow egress to kube-system on TCP/UDP port 53 and 169.254.169.254/32 on TCP ports 80 and 8080.A Kubernetes NetworkPolicy acts as a Layer 3 and Layer 4 firewall for selected Pods, moving workloads from a default-open cluster network to a strict least-privilege allowlist model. When policyTypes includes both Ingress and Egress, any connection not explicitly matched by a rule is denied.
namespaceSelector and podSelector inside the same ingress.from list item creates a logical AND relationship, allowing TCP port 8443 traffic exclusively from Pods labeled app: checkout-web inside the frontend namespace.53 to Pods in the kube-system namespace ensures internal Kubernetes service discovery and external hostname resolution continue functioning.169.254.169.254/32 on TCP ports 80 and 8080, allowing Pods to obtain federated Google Cloud credentials.Ingress and Egress in policyTypes blocks all unspecified inbound and outbound traffic.iptables chains.namespaceSelector and podSelector automatically tracks ephemeral Pod IPs as workloads scale or reschedule.frontend or payments is compromised.Unlike options that split selectors into separate OR entries, rely on ipBlock rules that ignore Pod traffic in Dataplane V2, or reference legacy Dataplane V1 metadata endpoints, this manifest accurately enforces every ingress, egress, and platform dependency.
policyTypes to ["Ingress", "Egress"] targeting app: payments-api, define a single ingress.from list item combining both namespaceSelector for frontend and podSelector for app: checkout-web on TCP port 8443, and configure a single egress.to rule using ipBlock with cidr: 0.0.0.0/0 to allow both DNS resolution and metadata server communication.This configuration correctly restricts incoming traffic using a combined namespaceSelector and podSelector, but attempts to simplify outbound rules by specifying a broad ipBlock CIDR of 0.0.0.0/0 in the egress section.
ipBlock rules. Even a 0.0.0.0/0 CIDR does not permit egress to kube-dns Pods in the kube-system namespace, causing DNS lookups to time out.0.0.0.0/0 via ipBlock opens outbound connectivity to all non-Pod destinations—including external internet addresses, VPC resources, and compute nodes—violating the mandate to deny all other egress traffic.ipBlock selectors are strictly intended for external or non-Pod IP ranges (such as load balancer health checks, corporate intranets, or the 169.254.169.254/32 metadata endpoint).ipBlock.cidr in Dataplane V2 environments; workloads must be referenced with label selectors.ipBlock: 0.0.0.0/0 implicitly matched Pod CIDRs unless excluded via except, Dataplane V2 isolates Pod traffic from ipBlock rules entirely.It cannot satisfy the strict least-privilege requirement in any scenario, though ipBlock: 0.0.0.0/0 would allow external non-Pod egress if you specifically intended to permit unrestricted outbound internet and infrastructure access while still needing separate podSelector and namespaceSelector rules for kube-dns.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated