2

According to some of the tech blogs (e.g. Understanding kubernetes networking: services), k8s service dispatch all the requests through iptable rules.
What if one of the upstream pods crashed when a request happened to be routed on that pods.
Is there a failover mechanism in kubernetes service?
Will the request will be forwarded to next pod automatically?
How does kubernetes solve this through iptable?

George Liang
  • 131
  • 1
  • 10

1 Answers1

2

Kubernetes offers a simple Endpoints API that is updated whenever the set of Pods in a Service changes. For non-native applications, Kubernetes offers a virtual-IP-based bridge to Services which redirects to the backend Pods

Here is the detail k8s service & endpoints

So your answer is endpoint Object

kubectl get endpoints,services,pods

There are liveness and readiness checks which decides if the pod is able to process the request or not. Kubelet with docker has mechanism to control the life cycle of pods. If the pod is healthy then its the part of the endpoint object.

Suresh Vishnoi
  • 17,341
  • 8
  • 47
  • 55
  • Thank you for your reply!But I've tested in my k8s service case with five pods deployed on three nodes. I restarted one of the nodes when I sending request at a speed of 1000 request per-seconds. Nearly 200 percent of the requests timeout per-second which lasted for 3 minutes. It seems k8s reacts too slow to detect the node error. Perhaps I should start another Question to state this problem... – George Liang Feb 19 '19 at 06:19
  • Hi, the Control plane wait certain amount of time to conclude that node is really down, to avoid the fluctuation of up and down, as well as replicaset can create new pods if it think current number of pods are not equal to number of desired pods. – Suresh Vishnoi Feb 19 '19 at 08:17
  • The default value of eviction is 5min , you can check it on the kubelet flags `podEvictionTimeout: 5m`\ – Suresh Vishnoi Feb 19 '19 at 08:18