|
| 1 | + |
| 2 | +## Retaining Client IPAddress |
| 3 | + |
| 4 | +Please read this https://kubernetes.github.io/ingress-nginx/user-guide/miscellaneous/#source-ip-address , to get details of retaining the client IPAddress. |
| 5 | + |
| 6 | +### Using proxy-protocol |
| 7 | + |
| 8 | +Please read this https://kubernetes.github.io/ingress-nginx/user-guide/miscellaneous/#proxy-protocol , to use proxy-protocol for retaining client IPAddress |
| 9 | + |
| 10 | + |
| 11 | +### Using the K8S spec service.spec.externalTrafficPolicy |
| 12 | + |
| 13 | +``` |
| 14 | +% kubectl explain service.spec.externalTrafficPolicy |
| 15 | +KIND: Service |
| 16 | +VERSION: v1 |
| 17 | +
|
| 18 | +FIELD: externalTrafficPolicy <string> |
| 19 | +
|
| 20 | +DESCRIPTION: |
| 21 | + externalTrafficPolicy describes how nodes distribute service traffic they |
| 22 | + receive on one of the Service's "externally-facing" addresses (NodePorts, |
| 23 | + ExternalIPs, and LoadBalancer IPs). If set to "Local", the proxy will |
| 24 | + configure the service in a way that assumes that external load balancers |
| 25 | + will take care of balancing the service traffic between nodes, and so each |
| 26 | + node will deliver traffic only to the node-local endpoints of the service, |
| 27 | + without masquerading the client source IP. (Traffic mistakenly sent to a |
| 28 | + node with no endpoints will be dropped.) The default value, "Cluster", uses |
| 29 | + the standard behavior of routing to all endpoints evenly (possibly modified |
| 30 | + by topology and other features). Note that traffic sent to an External IP or |
| 31 | + LoadBalancer IP from within the cluster will always get "Cluster" semantics, |
| 32 | + but clients sending to a NodePort from within the cluster may need to take |
| 33 | + traffic policy into account when picking a node. |
| 34 | + |
| 35 | + Possible enum values: |
| 36 | + - `"Cluster"` routes traffic to all endpoints. |
| 37 | + - `"Local"` preserves the source IP of the traffic by routing only to |
| 38 | + endpoints on the same node as the traffic was received on (dropping the |
| 39 | + traffic if there are no local endpoints). |
| 40 | +
|
| 41 | +``` |
| 42 | + |
| 43 | + |
| 44 | +- Setting the field `externalTrafficPolicy`, in the ingress-controller service, to a value of `Local` retains the client's ipaddress, within the scope explained above |
0 commit comments