What resource is created by the kubectl expose command?

Prepare for the Kubernetes Certified Network Administrator (KCNA) exam with our detailed tests. Use flashcards and multiple choice questions, complete with hints and explanations, to enhance your learning experience. Get exam-ready today!

Multiple Choice

What resource is created by the kubectl expose command?

Explanation:
The command kubectl expose creates a Service resource that provides a stable network endpoint and basic load balancing for a set of pods. It generates a Service that selects the pods from the specified workload (like a Deployment) using labels, and maps a port on the Service to a port on the pods (targetPort). By default the Service is cluster-internal (ClusterIP), but you can choose to expose it externally with NodePort or LoadBalancer. This is why the resource created by this command is a Service. Other resources like Deployment, Ingress, or ConfigMap are different kinds of objects and are not created by this command, even though you might want to expose a Deployment to traffic later via a Service.

The command kubectl expose creates a Service resource that provides a stable network endpoint and basic load balancing for a set of pods. It generates a Service that selects the pods from the specified workload (like a Deployment) using labels, and maps a port on the Service to a port on the pods (targetPort). By default the Service is cluster-internal (ClusterIP), but you can choose to expose it externally with NodePort or LoadBalancer. This is why the resource created by this command is a Service.

Other resources like Deployment, Ingress, or ConfigMap are different kinds of objects and are not created by this command, even though you might want to expose a Deployment to traffic later via a Service.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy