Bird
0
0

You want to access two different pods pod-a and pod-b running on ports 8080 and 9090 respectively, on your local machine at ports 3000 and 4000 simultaneously. Which commands should you run?

hard📝 Workflow Q15 of 15
Kubernetes - kubectl Essential Commands
You want to access two different pods pod-a and pod-b running on ports 8080 and 9090 respectively, on your local machine at ports 3000 and 4000 simultaneously. Which commands should you run?
Akubectl port-forward pod/pod-a 3000:8080; kubectl port-forward pod/pod-b 4000:9090
Bkubectl port-forward pod/pod-a 8080:3000 & kubectl port-forward pod/pod-b 9090:4000
Ckubectl port-forward pod/pod-a 3000:8080 & kubectl port-forward pod/pod-b 4000:9090
Dkubectl port-forward pod/pod-a 3000:8080 pod/pod-b 4000:9090
Step-by-Step Solution
Solution:
  1. Step 1: Understand port-forward syntax and concurrency

    Each port-forward command forwards one pod port to a local port. To run two simultaneously, run two commands in parallel using & or separate terminals.
  2. Step 2: Verify port mappings

    Local port 3000 maps to pod-a's 8080, and local 4000 maps to pod-b's 9090. The syntax is localPort:remotePort.
  3. Step 3: Check command correctness

    kubectl port-forward pod/pod-a 3000:8080 & kubectl port-forward pod/pod-b 4000:9090 correctly runs two commands in background with correct port mappings. kubectl port-forward pod/pod-a 3000:8080; kubectl port-forward pod/pod-b 4000:9090 runs sequentially, blocking second command.
  4. Final Answer:

    kubectl port-forward pod/pod-a 3000:8080 & kubectl port-forward pod/pod-b 4000:9090 -> Option C
  5. Quick Check:

    Run two port-forwards in parallel with correct local:remote ports [OK]
Quick Trick: Run separate port-forward commands in background for multiple pods [OK]
Common Mistakes:
  • Swapping local and remote ports
  • Trying to port-forward multiple pods in one command
  • Running commands sequentially blocking second port-forward

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes