Kubernetes: Endpoint

An Endpoint in Kubernetes is an object in Kubernetes that implements a Service. They represent the set of IPs for Pods that match a particular service. They are handy when you want to check that a Service actually matches some running pods. It provides a way to represent a remote system as an internal service. If an Endpoint is empty, then it means that there are no matching pods and something is most likely wrong with your service definition. Each Service object in Kubernetes has an associated Endpoint object. A corresponding endpoint with the same name of the Service is created when a Service is created with a Selector. The Endpoint of each Service in the cluster are being watched by the Kube-proxy for the purpose of routing network request made to virtual IPs to the endpoint which implements the Service. We can manually create Endpoints for a Service that has no Selector. Below is an example of a manually created Endpoint and it’s associated Service.

endpoint.yaml

kind: Endpoints
apiVersion: v1
metadata:
  name: test-endpoint
subsets:
  - addresses:
      - ip: 1.2.3.4
    ports:
      - port: 9376

service.yaml

kind: Service
apiVersion: v1
metadata:
  name: test-endpoint
spec:
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9376

Leave a Reply

Your email address will not be published. Required fields are marked *