What happens when a service receives a request but has no ready pods?

放肆的年华 提交于 2020-07-20 04:15:09

问题


Having a kubernetes service (of type ClusterIP) connected to a set of pods, but none of them are currently ready - what will happen to the request? Will it:

  • fail eagerly
  • timeout
  • wait until a ready pod is available (or forever, whichever is earlier)
  • something else?

回答1:


It will time out.

Kube-proxy pulls out the IP addresses from healthy pods and sets as endpoints of the service (backends). Also, note that all kube-proxy does is to re-write the iptables when you create, delete or modify a service.

So, when you send a request within your network and there is no one to reply, your request will timeout.




回答2:


Deployed nginx service

[node1 ~]$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 443/TCP 2h
my-nginx ClusterIP 10.100.1.134 80/TCP 9s

$ curl 10.100.1.134

curl: (7) Failed connect to 10.100.1.134:80; Connection refused

Deployed nginx deployment

$ kubectl create -f nginx-depl.yaml

$ kubectl get po
NAME READY STATUS RESTARTS AGE
my-nginx-f9945ffdd-2f77f 1/1 Running 0 1m
my-nginx-f9945ffdd-rk68v 1/1 Running 0 1m

$ curl 10.100.1.134

Welcome to nginx!

most likely you would get Connection refused error



来源:https://stackoverflow.com/questions/54569216/what-happens-when-a-service-receives-a-request-but-has-no-ready-pods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!