Some requests fails during autoscaling in kubernetes

ⅰ亾dé卋堺 提交于 2019-12-05 11:31:44

About your question:

I am not sure if the problem is Nginx or k8s?

According to ingress-nginx docs:

The NGINX ingress controller does not uses Services to route traffic to the pods. Instead it uses the Endpoints API in order to bypass kube-proxy to allow NGINX features like session affinity and custom load balancing algorithms. It also removes some overhead, such as conntrack entries for iptables DNAT

So I believe the problem is in Nginx, which does not make use of all Kubernetes features(e.g. kube-proxy) and is sending requests to Pods before they are completely ready.
However apparently this problem was fixed in 0.23.0 (Feb/2019), so you should check your version.
Personally, I experience less issues after switching from Ingress-Nginx to Ambassador, which by default forwards requests to Services (so Kubernetes is in charge of load balancing and sending it to the proper Pod).

cecunami

When the new pods are spawned, Kubernetes immediately starts to redirect traffic to them. However, usually, it takes a bit of time for the pod to boot and become operational (ready).

To prevent this from happening, you can define a Readiness Probe for your pods. K8s will periodically call the pod on the readiness endpoint that you have provided, to determine if this pod is functional and ready to accept requests. K8s won't redirect traffic to the pod until the readiness endpoints returns a successful result depending on the type of probe (check "Types of Probes" section).

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