Reputation: 2061
I have a cluster with 2 nodes:
I have created deployment, which creates 2 pods within the cluster. In my example it looks like:
Then I created a NodePort
service, which should route the traffic in some specific way. I was hoping for
But unfortunately it does not work this way. It looks like when I request a resource, and I keep requesting (refreshing a page), Pod1 (in the example) is handling the requests. Then, when I wait a bit (i.e. 1 minute) without any requests, and after this time I request the resource Pod2 starts to answer (and again, when I keep refreshing, Pod2 is still handling it).
Is it correct behavior? How can I make NodePort to route trafic in real 50/50 in this case?
Thanks
Upvotes: 0
Views: 345
Reputation: 2061
Ok, the answer was trivial, and not related to kubernetes configuration.
Since I was just using browser to access HTML page, some default HTTP headers was sent by browser. The one, which probably suggested to kubernetes to handle the request on same pod was Connection: keep-alive
.
Calling curl
or using Postman
and deleting the headers works as expected.
Upvotes: 2