如何在kubernetes的pod中的请求中获取真实IP [英] How to get the real ip in the request in the pod in kubernetes
问题描述
我必须从业务中的请求中获取真实的IP.实际上,每次在测试环境中我都得到了10.2.100.1
.有什么办法吗?
I have to get the real ip from the request in my business.actually I got the 10.2.100.1
every time at my test environment. any way to do this ?
推荐答案
这与如何从Kubernetes服务背后的HTTP请求中读取客户端IP地址?.
从他们那里得到的答案是,在发布的Kubernetes版本中这还不可能.
The answer, copied from them, is that this isn't yet possible in the released versions of Kubernetes.
服务通过kube_proxy进行响应,该响应会答复客户端连接并代理到后端(您的Web服务器).您所看到的地址将是连接通过的任何kube-proxy的IP.
Services go through kube_proxy, which answers the client connection and proxies through to the backend (your web server). The address that you'd see would be the IP of whichever kube-proxy the connection went through.
工作正在
Work is being actively done on a solution that uses iptables as the proxy, which will cause your server to see the real client IP.
这篇关于如何在kubernetes的pod中的请求中获取真实IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!