Bird
0
0

After running kubectl port-forward svc/my-service 8080:80, what occurs when you visit http://localhost:8080 in your browser?

medium📝 Command Output Q4 of 15
Kubernetes - kubectl Essential Commands
After running kubectl port-forward svc/my-service 8080:80, what occurs when you visit http://localhost:8080 in your browser?
AThe command exposes port 8080 externally to the internet.
BThe browser connects directly to the pod IP on port 8080.
CYour browser connects to port 80 of the service <code>my-service</code> via local port 8080.
DThe browser will fail to connect because port-forward only works with pods.
Step-by-Step Solution
Solution:
  1. Step 1: Understand port-forward with services

    Port-forward can forward to a service, forwarding local port to the service's target port.
  2. Step 2: Analyze the command

    Local port 8080 forwards to service port 80, so accessing localhost:8080 connects to service port 80.
  3. Final Answer:

    Your browser connects to port 80 of the service my-service via local port 8080. -> Option C
  4. Quick Check:

    Port-forward supports services, not just pods. [OK]
Quick Trick: Port-forward to service maps local port to service port [OK]
Common Mistakes:
  • Assuming port-forward only works with pods
  • Thinking it exposes ports externally
  • Confusing local port with pod port

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes