我在使用nginx-lego(我知道它已过时)和节点自动缩放器时遇到麻烦。我必须通过HPA手动扩展并临时将minReplicas修补为大量。一切都按比例缩放,由于 pods 增加,添加了新节点。
在流量激增之后,我将数字恢复为正常(这确实很低),并且可以看到很多错误的网关502错误。在检查了Nginx-lego Pod的日志之后,我发现大量请求都将发送到不再存在的Pod(连接被拒绝或没有通往主机的路由)。
2018/11/21 17:48:49 [error] 5546#5546: *6908265 connect() failed (113: No route to host) while connecting to upstream, client: 100.112.130.0, server: xxxx.com, request: "GET /public/images/social-instagram.png HTTP/1.1", upstream: "http://X.X.X.X:3000/public/images/social-instagram.png", host: "xxxx.com", referrer: "https://outlook.live.com/"
2018/11/21 17:48:49 [error] 5409#5409: *6908419 connect() failed (113: No route to host) while connecting to upstream, client: 10.5.143.204, server: xxxx.com, request: "GET /public/images/social-instagram.png HTTP/1.1", upstream: "http://X.X.X.X:3000/public/images/social-instagram.png", host: "xxxx.com"
2018/11/21 17:48:49 [error] 5546#5546: *6908420 connect() failed (111: Connection refused) while connecting to upstream, client: 10.5.143.204, server: xxxx.com, request: "GET /public/images/social-facebook.png HTTP/1.1", upstream: "http://X.X.X.X:3000/public/images/social-facebook.png", host: "xxxx.com"
有什么想法可能有问题吗?
我想打补丁minReplicas可能不是最好的方法,但是我知道会出现峰值,而且我对如何预扩展整个集群没有更好的主意。
最佳答案
缩小时,您的nginx入口(lego) Controller 似乎不更新nginx.conf
似乎是一个问题。我将检查nginx.conf
,并查看它是否指向不再存在的后端。
$ kubectl cp <nginx-lego-pod>:nginx.conf .
如果看起来有些奇怪,则可能必须删除容器,以便由管理您的nginx入口 Controller 容器的ReplicaSet创建。
$ kubectl delete <nginx-controller-pod>
然后再次检查
nginx.conf
。另一个问题可能是您的后端服务的端点没有被Kubernetes更新,但这与乐高HPA的升/降级没有直接关系。您可以通过以下方式进行检查:
$ kubectl get ep
看看是否有不存在的东西了。
关于amazon-web-services - 缩小后nginx-lego和autoscaler表现不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53418115/