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

2/7/2019

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?
-- orirab
kubernetes
kubernetes-health-check
kubernetes-service

2 Answers

2/7/2019

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

-- P Ekambaram
Source: StackOverflow

2/7/2019

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.

-- suren
Source: StackOverflow