I want to create a cluster of RESTful web APIs in AWS EKS and be able to access them through a single IP (allowing kubernetes to load balance requests to each). I have followed the procedure explained the this link and have set up an example nginx
deployment as shown in the following image:
The problem is that when I access the example nginx
deployment via 172.31.22.183
it works just fine, but when I try to use the cluster IP 10.100.145.181
it does not yield any response in such a way that it seems to be unreachable.
What’s the purpose of that cluster ip then and how can I use it to achieve what I need?
2
Answers
ClusterIP
is local IP that is used internally in the cluster, you can use it to access the application.While i think Endpoint IP that you got, is might be external and you can access the application outside.
For this best practice is to use the ingress, API gateway or service mesh.
Ingress is single point where all your request will be coming inside it will be load balancing and forwarding the traffic internally inside the cluster.
Consider ingress is like Loadbalancer single point to come inside the cluster.
Ingress : https://kubernetes.io/docs/concepts/services-networking/ingress/
AWS Example : https://aws.amazon.com/blogs/opensource/network-load-balancer-nginx-ingress-controller-eks/
ClusterIP
is an IP that is only accessible inside the cluster. You cannot hit it from outside cluster unless you usekubectl port-forward