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:
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.
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.
Final Answer:
kubectl expose pod mypod --port=80 --target-port=8080 --type=ClusterIP -> Option B
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
Master "Networking" in Kubernetes
9 interactive learning modes - each teaches the same concept differently