What resource is created by the kubectl expose command?

Study for the Kubernetes Certified Network Administrator Exam. Our test offers comprehensive flashcards, multiple-choice questions, and detailed explanations. Be confident for your exam!

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 Passetra

You can unsubscribe at any time. Read our privacy policy