Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant find x-real-ip in pod #1134

Closed
parswebserver opened this issue Jul 27, 2021 · 1 comment
Closed

cant find x-real-ip in pod #1134

parswebserver opened this issue Jul 27, 2021 · 1 comment
Labels

Comments

@parswebserver
Copy link

What happened?
hi

i use kube-router in kubernetes
when i run one pod with echoip image and i open pod url in browser (with nginx-ingress) this pod return pod ip instent of client real ip (x-real-ip)

when i use kube-proxy that return pod ip and when i use kube-router return master ip inside x-real-ip field and x-forwarded-for field

** System Information (please complete the following information):**

  • Kube-Router Version (kube-router --version): 1.3.0
  • Kube-Router Parameters: /usr/local/bin/kube-router --run-router=true --run-firewall=true --run-service-proxy=false --bgp-graceful-restart=true
  • Kubernetes Version (kubectl version) : v1.21.2
  • Cloud Type: vmware vps with 3 master and 2 worker
@aauren
Copy link
Collaborator

aauren commented Jul 27, 2021

I'm guessing that you used kube-proxy in iptables mode. A while back, the SIG-NET team did a lot of work to preserve the source IP in iptables mode: kubernetes/kubernetes#3760

However, kube-router and kube-proxy in ipvs mode uses ipvs which does full source NAT'ing by default. There have been a number of efforts to bring this back in ipvs mode: kubernetes/kubernetes#62537 kubernetes/kubernetes#59976 but I believe that all of them haven't made traction.

For kube-router, NAT'ing the source IP is just part of the way that we make our clusters a bit easier to manage. If you have a need to preserve the source IP, I would recommend looking into kube-router's DSR functionality: https://github.com/cloudnativelabs/kube-router/blob/master/docs/user-guide.md#direct-server-return

This will do more than what you want to do, but it will preserve the source IP. The other alternative (although it comes with a lot of drawbacks) would be to run your workload in the host's network namespace, then no source nat'ing would be done either.

@aauren aauren closed this as completed Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants