# Best way to preserve source ip address in k8s?

**URL:** <https://community.traefik.io/t/best-way-to-preserve-source-ip-address-in-k8s/3625>\
**Category:** Traefik v2\
**Tags:** kubernetes-crd\
**Created:** [December 30, 2019, 3:19pm UTC](https://community.traefik.io/t/best-way-to-preserve-source-ip-address-in-k8s/3625 "2019-12-30T15:19:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rxwen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/rxwen/32/1213_2.png) [@rxwen](https://community.traefik.io/u/rxwen)\
**Post date:** [December 30, 2019, 3:19pm UTC](https://community.traefik.io/t/best-way-to-preserve-source-ip-address-in-k8s/3625/1 "2019-12-30T15:19:24Z")

</div>

Hi,

We used traefik (v2.1) in a k8s cluster. It's deployed as a deployment with a nodeport service to expose it to external.  
The problem is with our k8s configuration, traefik isn't able to get client's real source ip address. We get a cluster ip instead. It's more a k8s configuration.

One way we can think of is to place a traefik instance outside the k8s as a load balancer, and ask it to preserve the real client ip in X-Forwarded-For http header, and then proxy the traffic to the k8s service.  
I'm not sue if this is the right approach to solve the probelm? Any other ideas?

Thanks.

---

<div class="post-metadata">

**Author:** ![rxwen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/rxwen/32/1213_2.png) [@rxwen](https://community.traefik.io/u/rxwen)\
**Post date:** [December 30, 2019, 11:27pm UTC](https://community.traefik.io/t/best-way-to-preserve-source-ip-address-in-k8s/3625/2 "2019-12-30T23:27:07Z")

</div>

And I'm aware that k8s points out how to preserve source ip here ([https://kubernetes.io/docs/tutorials/services/source-ip/](https://kubernetes.io/docs/tutorials/services/source-ip/)), but it's not practical to use Local service.spec.externalTrafficPolicy in our setup.

---

<div class="post-metadata">

**Author:** ![Zword](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zword/32/899_2.png) [@Zword](https://community.traefik.io/u/Zword)\
**Post date:** [January 14, 2020, 6:58am UTC](https://community.traefik.io/t/best-way-to-preserve-source-ip-address-in-k8s/3625/3 "2020-01-14T06:58:19Z")

</div>

Hello @rxwen,

Have a look to my post here : [Rancher - Traefik - Host Network](https://forums.rancher.com/t/tutorial-traefik-2-0-baremetal-rancheros-hetzner-ovh/15768/4?u=zwordi)  
I had kind of the same behaviour and question :).

Have a good day,
