<p>I've installed kubernetes 1.2.0 with the following configuration</p>

<pre><code>export nodes="user@10.0.0.30 user@10.0.0.32"
export role="ai i"
export NUM_NODES=2
export SERVICE_CLUSTER_IP_RANGE=192.168.3.0/24
export FLANNEL_NET=172.16.0.0/16
export KUBE_PROXY_EXTRA_OPTS="--proxy-mode=iptables"
</code></pre>

<p>I've created a nginx pod and expose with load balancer and external IP address</p>

<pre><code>kubectl expose pod my-nginx-3800858182-6qhap --external-ip=10.0.0.50 --port=80 --target-port=80
</code></pre>

<p>I'm using kubernetes on bare metal so i've assigned 10.0.0.50 ip to master node.</p>

<p>If i try curl 10.0.0.50 (from outside kubernetes) and use tcpdump on nginx pod i see traffic, the source ip is always from the kubernetes master node</p>

<pre><code>17:30:55.470230 IP 172.16.60.1.43030 &gt; 172.16.60.2.80: ...
17:30:55.470343 IP 172.16.60.2.80 &gt; 172.16.60.1.43030: ...
</code></pre>

<p>i'm using mode-proxy=iptables. and need to get the actual source ip. what am i doing wrong ?</p>

<p>This was added as an annotation in Kubernetes 1.5 (docs <a href="https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer#annotation-to-modify-the-loadbalancer-behavior-for-preservation-of-source-ip" rel="nofollow noreferrer">here</a>).</p>

<p>In 1.7, it has graduated to GA, so you can specify the load balancing policy on a Service with <code>spec.externalTrafficPolicy</code> field (docs <a href="https://github.com/MrHohn/kubernetes.github.io/blob/9cbed0cc6d1725c6eca4513fb2c8ed52b3bce04e/docs/tasks/access-application-cluster/create-external-load-balancer.md" rel="nofollow noreferrer">here</a>):</p>

<pre><code>{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "example-service",
  },
  "spec": {
    "ports": [{
      "port": 8765,
      "targetPort": 9376
    }],
    "selector": {
      "app": "example"
    },
    "type": "LoadBalancer",
    "externalTrafficPolicy": "Local"
  }
}
</code></pre>
