gpt4 book ai didi

nginx - 在哪里可以找到为nginx.ingress.kubernetes.io/affinity注释生成的配置

转载 作者:行者123 更新时间:2023-12-02 12:15:45 24 4
gpt4 key购买 nike

设置以下注释时:

nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "ALPHA"
nginx.ingress.kubernetes.io/session-cookie-path: /

它们最终在哪里出现在nginx.conf中?

我正在使用difftool来比较nginx.conf之前和之后,但是配置是相同的。

如果我添加:
nginx.ingress.kubernetes.io/rewrite-target /$1

nginx.conf更新。

结果是:
rewrite "(?i)/myapp(/|$)(.*)" /$2 break;

最佳答案

简短的答案是这些设置存在于nginx-ingress使用的lua nginx module的内存中。

https://kubernetes.github.io/ingress-nginx/how-it-works中的文档提供了对此方法的更详细的解答和解释。尤其:

Though it is important to note that we don't reload Nginx on changes that impact only an upstream configuration (i.e Endpoints change when you deploy your app). We use https://github.com/openresty/lua-nginx-module to achieve this. Check below to learn more about how it's done.



然后,下面引用的部分提到:

On every endpoint change the controller fetches endpoints from all the services it sees and generates corresponding Backend objects. It then sends these objects to a Lua handler running inside Nginx. The Lua code in turn stores those backends in a shared memory zone. Then for every request Lua code running in balancer_by_lua context detects what endpoints it should choose upstream peer from and applies the configured load balancing algorithm to choose the peer.



有问题的后端对象具有 session 和cookie信息。接收此代码的代码位于 https://github.com/kubernetes/ingress-nginx/blob/57a0542fa356c49a6afb762cddf0c7dbf0b156dd/rootfs/etc/nginx/lua/balancer/sticky.lua#L151-L166。特别是在同步功能中有以下这一行:
ngx_log(INFO, string_format("[%s] nodes have changed for backend %s", self.name, backend.name))

这表示在对后端进行此类更改时,应该在nginx日志中看到有关更改的日志条目。

关于nginx - 在哪里可以找到为nginx.ingress.kubernetes.io/affinity注释生成的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56658923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com