CKA Services and Networking Practice Question
You want to forward local port 8080 to port 80 of a pod named 'nginx-pod'. Which command should you use?
⚠ Common exam trap
Watch out — candidates often confuse `kubectl port-forward` with `kubectl proxy` or misremember the syntax, leading them to choose a non-existent command like `kubectl forward` or incorrectly assume that a service must always be used for port forwarding.
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/nginx-pod 8080:80
`kubectl port-forward` is the Kubernetes command used to forward a local port to a port on a specific pod. The syntax `kubectl port-forward pod/nginx-pod 8080:80` correctly specifies the pod resource, the local port (8080), and the target pod port (80), enabling access to the pod's port 80 from the local machine.
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 proxy pod/nginx-pod 8080:80
Why it's wrong here
The `kubectl proxy` command is designed to establish a secure connection between localhost and the Kubernetes API server, allowing you to access the API locally without manual authentication. It does not support direct port forwarding to individual pods or accept the `local-port:remote-port` syntax, making this command syntactically and functionally incorrect for this task.
- ✓
kubectl port-forward pod/nginx-pod 8080:80
Why this is correct
This is the correct command and syntax for forwarding traffic from a local port to a pod. The `kubectl port-forward` subcommand targets the `pod/nginx-pod` resource and maps local port 8080 to the container's port 80, establishing a secure tunnel via the API server.
- ✗
kubectl forward pod/nginx-pod 8080 80
Why it's wrong here
There is no `forward` subcommand in the `kubectl` CLI utility, which results in a command-line syntax error. Additionally, port mapping in Kubernetes requires a colon separator (`local:remote`) rather than space-separated port arguments to define the source and destination ports.
- ✗
kubectl port-forward service/nginx-pod 8080:80
Why it's wrong here
This command incorrectly specifies the resource type as `service/nginx-pod` instead of `pod/nginx-pod`. While `kubectl port-forward` can target services, this specific command would fail unless a Service resource named `nginx-pod` actually existed in the namespace to route the traffic.
Go deeper
Related to this question
Learn chapter
Kubernetes Architecture Overview
Key term
kubectl Command Reference
kubectl is the command-line tool used to interact with and manage Kubernetes clusters by sending commands to the Kubernetes API.
Key term
Ingress Resources
Ingress Resources are Kubernetes API objects that manage external access to services inside a cluster, typically HTTP and HTTPS traffic, by defining rules for routing requests based on hostnames and paths.
About these practice questions
This CKA question is part of Courseiva's 726-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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA 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 CKA exam.