How to support internal traffic with proxy protocol enabled on a Kubernetes loadbalancer

November 29, 2019 160 views
DigitalOcean Managed Kubernetes

Enabling proxy protocol on a Kubernetes ingress load balancer only works with requests that come from outside the cluster. Requests from inside the cluster break.

This seems to be because requests from inside the cluster don’t get routed through the load balancer, so don’t get proxy protocol headers applied. The ingress controller then seems to fail to parse the request correctly, as it is expecting proxy protocol headers.

When proxy protocol is disabled, the ingress controller sees external traffic coming from a droplet subnet IP (presumably the loadbalancer IP), and internal traffic coming directly from a cluster pod subnet IP (interestingly, this isn’t the actual pod IP).

Note that this also means other DigitalOcean load balancer features don’t work for internal traffic, e.g. HTTPS redirection.

I haven’t been able to determine if this is due to the DigitalOcean LoadBalancer service implementation, or a feature of Kubernetes itself.

Either way, it means that I can’t use proxy protocol, as I have services that must be accessible inside and out of the cluster on the same hostname. It’d be great if there was some way to disable this behaviour, or some kind of workaround.

LoadBalancer service config for reference:

apiVersion: v1
kind: Service
  name: kong-proxy
  namespace: kong
  annotations: "http" "round_robin" "443" "true" "true" "true"
  type: LoadBalancer
    app: ingress-kong
  - name: proxy
    port: 80
    protocol: TCP
    targetPort: proxy
  - name: proxy-ssl
    port: 443
    protocol: TCP
    targetPort: proxy-ssl
  externalTrafficPolicy: Local
Be the first one to answer this question.