Hi guys, Are endpoints same as services? I mean whenever we expose any resource using
kubectl expose it create a service which can be seen using
kubectl get ep so how are the
services different from
endpoints are the backend pods of a service. clients usually know only the services (not the endpoints). When clients send a request to service, the service will load balance traffic to one of the endpoint pods. hope this helps.
Also, if you create a service with no pod selector, then no endpoints are created. In this case, you’d have to manually create endpoints for the service. Why would you do this? I don’t remember–only that I read about it recently and that it sometimes comes in handy.
For statefulsets service with out selector we use
If you don’t want/need load balancing, you can also create a headless service. You get the same endpoints but without the load balancing aspect.
@Gautam Venkataramanan I am still not clear. So, if there are 100 pods, then the
kubectl get ep shall list these 100s IPs in the endpoint column?
Yes. Try the command. Here is a service with three pods.
@R S, correct. But if you just create pods and dont tie it to any service, then those wont be listed under endpoints.
Ok, after messing up some time with multi-container pods and services with multiple ports. I realised that and endpoint will be created by service for each ports mentioned or supplied to service.
## Pod 3
- name: httpd
- containerPort: 8086
- name: redis
- containerPort: 8087
- name: svc-port1
- name: svc-port2