Unable to configure UDP on ingress-nginx-controller

7/25/2019

I use Azure Kubernetes to host a couple of different services.

I'm trying to configure UDP load balancing over external IP. I have created service with type LoadBalancer, UDP protocol and sessionAffinity. Also my deployment has configured HTTP RedinessProbe.

If UDP client reach my service from kubernetes network every thing works fine: - client have sticky session to concrete pod in ready state. - client re-balanced to another ready pod if already assigned pod was dead; - client re-balanced after sessionAffinityConfig.clientIP.timeoutSeconds is elapsed(i.e next packets may be routed to other ready pod).

Thinks go different if I try to connect to LoadBalancer externally(using external IP): - client have sticky session to concrete pod in ready state. - client doesn't get new ready pod if previous was dead. It connected to new pod only in case If client stop to send messages during sessionAffinityConfig.clientIP.timeoutSeconds period of time.

So to solve it I tried to use ingress-nginx. I found useful article here about this kind of configuration.

But after I completed with udp-service configuration and adding UDP port I get following error:

cannot create an external load balancer with mix protocols

Could You please point me how to do it properly in Kubernetes.

udp-services config map:

kind: ConfigMap
apiVersion: v1
metadata:
  name: udp-services
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
data:
  5684: "dev/dip-dc:5684"

ingress-nginx controller service YAML:

kind: Service
apiVersion: v1
metadata:
name: ingress-nginx2
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
externalTrafficPolicy: Local
type: LoadBalancer
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: https
- name: upd
port: 5684
targetPort: udp
-- Zheko
kubernetes
kubernetes-ingress
nginx-ingress
udp

1 Answer

7/25/2019

A multi-protocol LB service is unfortunately not supported in many K8S providers.

Check out this tutorial that shows you how to build your own UDP/TCP load balancer.

The summary of what you will need to do is:

  1. Create a NodePort service for your application
  2. Create a small server instance and run Nginx with LB config
-- cookiedough
Source: StackOverflow