<p>Does anyone know if and how I can access the origin IP-Address of the client originally performed the request if I have a LoadBalancer service in OpenShift? It is overwritten by the Load-Balancer's IP-Address.</p>

<p>There should be a way to access that information - may be in the optional TCP data or so. Does anyone know?</p>

<p>Or maybe I can use a different approach to forward the package without losing that information but still being able to scale the service to multiple Pod's. Thank you for any hint!</p>

<p>Best regards, Dominic</p>

<p>OpenShift Master: v3.9.41
Kubernetes Master: v1.9.1</p>

Dominic
<p>IP addresses are source NAT'ed by default in Kubernetes services as of K8s 1.5, so you won't see the source IP. For <code>LoadBalancer</code> type of service you can set in its spec the <a href="https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-type-loadbalancer" rel="nofollow noreferrer"><code>externalTrafficPolicy</code> field to <code>Local</code></a> to preserve the source IP address:</p>

<pre><code>$ kubectl patch svc yourservice -p '{"spec":{"externalTrafficPolicy":"Local"}}'
</code></pre>

<p>It should work out the box for the GCE and Azure <a href="https://kubernetes.io/docs/concepts/cluster-administration/cloud-providers/" rel="nofollow noreferrer">cloud providers</a>. For others follow the 'Cross platform support' section <a href="https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-type-loadbalancer" rel="nofollow noreferrer">here</a>.</p>

<p>Quoted from the docs:</p>

<blockquote>
  <p>As of Kubernetes 1.5, support for source IP preservation through Services with Type=LoadBalancer is only implemented in a subset of cloudproviders (GCP and Azure). </p>
</blockquote>

<p>Note that when you set the <code>externalTrafficPolicy</code> field to <code>Local</code>, only the nodes where your pod is running will show as healthy because they are ones replying to your service.</p>

<p>OpenShift uses the same Kubernetes Service syntax.</p>
