Certified Kubernetes Administrator (CKA) Practice Test

Question: 1 / 400

To expose a port on the containers in a deployment's pods, which command is appropriate?

kubectl expose deployment

kubectl edit deployment

The most appropriate command to expose a port on the containers in a deployment's pods is "kubectl expose deployment." This command creates a service resource that exposes the deployment, allowing access to the pods through a network port.

Using "kubectl edit deployment" allows you to modify the deployment specification directly, including container definitions and other configurations, but it does not automatically create a service to expose your pods. While you could edit the deployment to add the necessary ports within the container specification, this is not the efficient method for exposing a deployment.

Similarly, "kubectl create deployment" is used to create a new deployment but does not address the need to expose an existing deployment's pods. It is focused solely on deployment creation rather than exposure.

The command "kubectl apply -f deployment.yaml" is used for applying changes defined in a YAML configuration file. While this could potentially include exposing a service if the service definition is also part of the YAML file, it does not directly address the action of exposing a port on the deployment's pods without additional context.

In summary, to specifically expose a port on the containers in a deployment's pods, "kubectl expose deployment" is the correct and most straightforward command.

Get further explanation with Examzify DeepDiveBeta

kubectl create deployment

kubectl apply -f deployment.yaml

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy