Certified Kubernetes Application Developer (CKAD) Practice Test

Session length

1 / 400

How can you expose a deployment as a service?

kubectl show deployment [deployment-name] --type=[service-type]

kubectl expose deployment [deployment-name] --type=[service-type] --port=[port-number]

To expose a deployment as a service in Kubernetes, using the command that invokes the `expose` action is the correct approach. The command structure `kubectl expose deployment [deployment-name] --type=[service-type] --port=[port-number]` specifically serves to create a service resource based on an existing deployment.

The emphasis here is on the command itself, which is specifically designed for this purpose. When you use the `expose` command, you are informing Kubernetes to create a service that points to the pods managed by the specified deployment. The `--type` flag allows you to specify the desired service type, such as `ClusterIP`, `NodePort`, or `LoadBalancer`, which determines how the service is accessed. The `--port` flag specifies the port that the service will listen on, which is crucial for directing traffic appropriately.

This command effectively connects the service to the deployment's pods, allowing them to be accessed externally based on the specified service type and port settings. This connection between the deployment and the service is fundamental in microservices architecture and is crucial for managing the traffic to your applications.

The other options don't align with the standard Kubernetes commands used to expose resources. For example, the command that uses "show

Get further explanation with Examzify DeepDiveBeta

kubectl publish deployment [deployment-name] --type=[service-type]

kubectl create service from deployment [deployment-name] --type=[service-type]

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy