PSKP
PSKP

Reputation: 1365

source IP using AKS azure internal load balancer

I am creating internal load balancer like below

---
kind: Service
apiVersion: v1
metadata:
  name: nginx
  namespace: alts
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-internal: "true"
  labels:
    k8s-app: nginx
spec:
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
  selector:
    k8s-app: nginx
  type: LoadBalancer

enter image description here

But the issue is my app (APP in image) is not able to get the private IP of VM (Original source) it is getting the source as a load balancer.

Pls suggest an answer or workaround.

Upvotes: 0

Views: 1143

Answers (1)

I suggest two approaches. In one of my clusters, I used exernalTrafficPolicy=Local but as explained in this article, doing this just happened to keep the source IP. Alternatively, you may look at the X-Forwarded-For header in your app.

More info: https://medium.com/pablo-perez/k8s-externaltrafficpolicy-local-or-cluster-40b259a19404

Upvotes: 1

Related Questions