Kubernetes 101 : Services, deployments and endpoints - Bypassing the ClusterIP service -

The clusterIP service is a fixed "entrypoint" to the pods and to the application running in them.

Other services like the nodeBalancer or the nodePort, also make use of the clusterIP service to communicate with the pods. 

If a service or an application wants to connect directly to the
pods without going through a clusterIP service, they need to use a kubernetes object called endpoints.

The endpoints:

Endpoints could be described as a group of IP addresses that a service forwards its requests to.

We have for example the below deployment:

We create our deployment using the below command:

The above deployment spawns two replicas "pods" of "nginx".

Displaying the addresses of the two pods:

To see the IP addresses of the above pods, we use the below command:

We also need to create a service to have access to the above "nginxpods:

We then create our service using the below command:

We can display our service using the below command:

Displaying the endpoints of our service:

We display the endpoints our "nginx-service" forwards its requests to using the below command:

We could bypass the clusterIP service and directly reach the "nginx" application running inside the pods using the addresses :



Leave as a comment: