I noticed when accessing the Kubernetes Service, the host ip is ignored by the kubernetes.
For example: I have 3 kubernetes workers, hostIP1
, hostIP2
and hostIP3
, on each worker, i create a pod, with label: app = test
. In each pod, it just simple runs python -m SimpleHTTPServer 32000
, I then create a service to expose port: 32000
so that it can be accessed outside the cluster.
But when I access http://hostIP1:32000
, the traffic is actually routed to any of the hosts, hostIP1
, hostIP2
and hostIP3
Is there a way to only let Kubernetes forward traffic to hostIP1
when accessing http://hostIP1:32000
?
Thanks
You can't do that. If your pods have the same label, they are going to be selected by the same service, and every time you hit that service it is going to balance the load among the backends it has, which are your pods.
To do what you want, you have to create 3 different services, to point each service to its own backend.