Courseiva
Services and Networking →mediumMultiple Choice

CKAD Services and Networking Practice Question

Which command forwards local port 8080 to port 80 of a pod named 'web-pod'?

⚠ Common exam trap

It's easy for candidates to confuse the port order (local:pod) or incorrectly assume that `kubectl port-forward` works with any resource type like Deployments, when in fact it only supports pods and services (and some other specific types).

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

✓

kubectl port-forward pod/web-pod 8080:80

`kubectl port-forward` requires the resource type and name, and for a pod, the syntax is `pod/<pod-name>`. The command `kubectl port-forward pod/web-pod 8080:80` forwards local port 8080 to port 80 of the pod, matching the question's requirement exactly.

Answer analysis

Option-by-option breakdown

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

  • ✗

    kubectl port-forward service/web-service 8080:80

    Why it's wrong here

    The service/web-service form of kubectl port-forward targets a Service object, not a specific Pod. Since the question asks to forward to a pod named web-pod, using a Service would route to whichever Pods are currently backing that Service's selector, not necessarily web-pod. This command has valid syntax, but it fails the requirement of a direct, pod-specific tunnel to web-pod.

  • ✓

    kubectl port-forward pod/web-pod 8080:80

    Why this is correct

    This is the correct command because kubectl port-forward is given the resource type pod, the exact pod name web-pod, and the port mapping 8080:80, where the format is LOCAL_PORT:REMOTE_PORT. It opens a direct TCP tunnel from localhost:8080 on your workstation to port 80 of web-pod's IP, bypassing Services and Deployments. This ensures traffic reaches that exact pod, which is what the question specifies.

  • ✗

    kubectl port-forward deployment/web-deployment 8080:80

    Why it's wrong here

    Targeting deployment/web-deployment with kubectl port-forward uses the Deployment's selector to choose an arbitrary healthy Pod among its replicas. The command does not resolve to the specific pod named web-pod; it may pick any Pod managed by that Deployment, making the target nondeterministic. Since the question explicitly requires forwarding to web-pod, relying on a Deployment's pod selection is incorrect, even though the port-forward syntax itself is otherwise valid.

  • ✗

    kubectl port-forward pod/web-pod 80:8080

    Why it's wrong here

    The order of the ports is reversed: kubectl port-forward expects LOCAL_PORT:REMOTE_PORT, so 80:8080 would listen on your local port 80 and forward to port 8080 on web-pod. This is the opposite of the requested mapping, which is local 8080 to pod port 80. Even though the resource specifier pod/web-pod is correct, the port pair does not match the question's requirement.

About these practice questions

Courseiva writes every CKAD question from scratch — 826 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 CKAD 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 CKAD exam.