Question 14
Domain 4: Services, Networking, and Service DiscoveryWhich kubectl command exposes an existing Deployment named "my-deployment" as a ClusterIP Service on port 80 targeting container port 8080?
Correct answer: A
Explanation
`kubectl expose` creates a Service from an existing workload, and `--type=ClusterIP` makes it an internal ClusterIP Service. The flags `--port=80` and `--target-port=8080` map Service port 80 to the container’s port 8080, which matches the command shown.
Why each option is right or wrong
A. kubectl expose deployment my-deployment --type=ClusterIP --port=80 --target-port=8080
`kubectl expose` is the command used to generate a Service from an existing Deployment object, and the Service type is set with `--type=ClusterIP` under the Kubernetes Service API (`v1/Service`). The port mapping is explicit: `--port=80` defines the Service port, while `--target-port=8080` directs traffic to the Pod/container port 8080, which is the required 80→8080 translation in this question.
B. kubectl create service clusterip my-deployment --tcp=80:8080
C. kubectl expose service my-deployment --type=ClusterIP --port=80 --target-port=8080
D. kubectl run my-deployment --port=80 --target-port=8080