Bird
0
0

Which of the following is the correct way to expose a Pod using a Service in Kubernetes?

easy📝 Syntax Q12 of 15
Kubernetes - Networking
Which of the following is the correct way to expose a Pod using a Service in Kubernetes?
Akubectl service create mypod --port=80
Bkubectl expose pod mypod --port=80 --target-port=8080 --type=ClusterIP
Ckubectl create pod mypod --expose --port=80
Dkubectl expose service mypod --port=80
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct command to expose a Pod

    The command 'kubectl expose pod' is used to expose a Pod as a Service with specified ports and type.
  2. Step 2: Check syntax correctness

    kubectl expose pod mypod --port=80 --target-port=8080 --type=ClusterIP uses correct syntax with --port, --target-port, and --type flags. Other options use invalid commands or flags.
  3. Final Answer:

    kubectl expose pod mypod --port=80 --target-port=8080 --type=ClusterIP -> Option B
  4. Quick Check:

    Expose Pod = kubectl expose pod [OK]
Quick Trick: Use 'kubectl expose pod' with ports and type [OK]
Common Mistakes:
  • Using 'kubectl create pod' to expose
  • Trying to expose a service instead of a pod
  • Missing required flags like --port

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes