Services and Endpoints Objects

Learn about Endpoints objects and the types of Services.

We'll cover the following

Whenever we create a Service, Kubernetes automatically creates an associated EndpointSlice to track healthy Pods with matching labels.

It works like this:

We create a Service, and the EndpointSlice controller automatically creates an associated EndpointSlice object. Kubernetes then watches the cluster, looking for Pods matching the Service’s label selector. Any new Pods matching the selector are added to the EndpointSlice, whereas any deleted Pods get removed. Applications send traffic to the Service name, and the application’s container uses the cluster DNS to resolve the name to an IP address. The container then sends the traffic to the Service’s IP, and the Service forwards it to one of the Pods listed in the EndpointSlice.

Older versions of Kubernetes used an Endpoints object instead of EndpointSlices. They’re functionally identical, but EndpointSlices perform better on large busy clusters.

Service types

Kubernetes has several types of Services for different use cases and requirements. The major ones are:

  • ClusterIP

  • NodePort

  • LoadBalancer

ClusterIP is the most basic and provides a reliable endpoint (name, IP, and port) on the internal Pod network. NodePort Services build on top of ClusterIP and allow external clients to connect via a port on every cluster node. LoadBalancers build on top of both and integrate with cloud load balancers for extremely simple access from the internet.

All three are important, and we'll look at each of them.

Get hands-on with 1400+ tech skills courses.