Courseiva
Services and Networking →easyMultiple Choice

CKAD Services and Networking Practice Question

You need to forward a local port to port 8080 on a pod named 'my-pod' in the 'default' namespace. Which kubectl command should you use?

⚠ Common exam trap

The trap here is that candidates often forget to include the resource type prefix (`pod/`) or confuse the port mapping order, leading them to choose options like A or D, which either map to the wrong port or omit the required resource type.

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/my-pod 8080:8080

The `kubectl port-forward` command requires the resource type (pod/) and the correct port mapping syntax. The question specifies forwarding a local port to port 8080 on the pod, so the local port is 8080 and the pod port is 8080, making `8080:8080` the correct mapping. The full command `kubectl port-forward pod/my-pod 8080:8080` establishes a tunnel from localhost:8080 to the pod's port 8080.

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 pod/my-pod 8080:80

    Why it's wrong here

    The command is syntactically valid but the port mapping is incorrect: the local port 8080 is mapped to port 80 on the pod, so traffic sent to localhost:8080 would reach the pod's port 80 instead of port 8080. To satisfy the requirement, both the local port and the pod's port must be 8080, making the mapping 8080:8080. This would fail to provide access to the application that is actually listening on port 8080 of the pod.

  • ✓

    kubectl port-forward pod/my-pod 8080:8080

    Why this is correct

    This command is correct because it explicitly names a pod resource using the 'pod/' prefix and maps local port 8080 to the pod's port 8080, exactly as required. The syntax 'kubectl port-forward pod/my-pod 8080:8080' creates a tunnel from localhost:8080 to port 8080 on the specified pod, allowing direct access to the application running there. It is the only option that both uses the correct verb and targets the pod with the proper port pairing.

  • ✗

    kubectl forward pod/my-pod 8080:8080

    Why it's wrong here

    There is no 'kubectl forward' subcommand in the Kubernetes CLI; the only valid verb for this operation is 'port-forward'. Running this will cause kubectl to return an error stating that the command is not recognized, and no port forwarding will occur. Even if the verb were corrected to 'port-forward', the rest of the command would be structurally valid, but as given it cannot be executed.

  • ✗

    kubectl port-forward my-pod 8080

    Why it's wrong here

    Omitting the 'pod/' prefix changes how kubectl interprets the first positional argument: without a resource type, kubectl assumes you are referring to a service, not a pod. This means it will attempt to port-forward a service named 'my-pod' and will either fail if no such service exists or forward to the wrong resource if one does. The correct syntax for a pod must include the resource type, as in 'pod/my-pod' or 'pods/my-pod'.

About these practice questions

This CKAD question is part of Courseiva's 826-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.