What Are Kubernetes Endpoints?

And how to use them?

Neil Shah
3 min readMar 21, 2023
Created by the Author

If you are a developer or a system administrator working with Kubernetes, then you must have heard about Kubernetes endpoints. Kubernetes endpoints are a critical component of Kubernetes networking, and they are used to connect Kubernetes services to their backend pods.

In this article, we will discuss what Kubernetes endpoints are, why they are important, and how to use them in your Kubernetes clusters.

What Are Kubernetes Endpoints?

Kubernetes endpoints are essentially a collection of IP addresses and port numbers that define the backend pods associated with a Kubernetes service.

They are ways to tell Kubernetes where the backend pods are located and how to connect to them. Kubernetes endpoints are created automatically by Kubernetes, and they are updated dynamically as pods are created, deleted, or modified.

Also, you can create your own custom endpoint but it depends on the individual use cases.

Why Are Kubernetes Endpoints Important?

Kubernetes endpoints are essential for two reasons:

  • Service Discovery

Kubernetes endpoints are used to discover the backend pods associated with a Kubernetes service. When a Kubernetes service is created, Kubernetes creates a corresponding set of endpoints that point to the backend pods.

When a client sends a request to the service, Kubernetes uses the endpoints to route the request to one of the backend pods. This allows Kubernetes to provide load balancing and high availability for services, as well as enable seamless scaling and deployment of new pods.

  • Network Policy

Kubernetes endpoints are also used to enforce network policies. Network policies define how traffic is allowed to flow between pods in a Kubernetes cluster.

By using endpoints to identify pods, Kubernetes can apply network policies to specific pods or groups of pods. This allows you to control access to your services and ensure that they are secure and isolated from other parts of your cluster.

How to Use Kubernetes Endpoints?

Using Kubernetes endpoints is relatively straightforward. Kubernetes creates endpoints automatically when you create a service, and you can access the endpoints using the Kubernetes API. You can also use the kubectl command-line tool to interact with endpoints.

To access endpoints using the Kubernetes API, you can use the following command:

kubectl get endpoints <service-name>

This will give you a list of the endpoints associated with the service, along with their IP addresses and port numbers.

To create endpoints manually, you can use the following YAML file:

apiVersion: v1
kind: Endpoints
name: <endpoint-name>
— addresses:
— ip: <pod-ip-address>
— port: <pod-port>
name: <port-name>

This YAML file defines an endpoint that points to a single pod. You can use the addresses and ports fields to define multiple pods and ports, respectively.

Once you have created endpoints, you can use them to configure your services. To do this, you can add the endpoints field to your service definition:

apiVersion: v1
kind: Service
name: <service-name>
<selector-label>: <selector-value>
— name: <port-name>
port: <service-port>
targetPort: <pod-port>
— <endpoint-name>

This YAML file defines a service that uses the endpoint we defined earlier. The targetPort field in the ports the section specifies the port that the service should use to connect to the backend pod.


In conclusion, Kubernetes endpoints are a fundamental building block of Kubernetes networking. By following the steps outlined in this article, you can use endpoints effectively in your Kubernetes clusters and build applications that are scalable, reliable, and secure.



Neil Shah

200K+ Views | DevOps | Philosophy | Cinema | Psychology | 👉🏻 Support: https://ko-fi.com/xshahneil