I'm having an issue with port forwarding UDP traffic in kubernetes. I am running a coreos baremetal setup and in the past just used fleet to run my containers, so these containers to work and my network and port forwarding is setup correctly. I can manually run the container and port forward to it and things work as expected, so it seems something is going on with kubernetes and UDP. I have multiple services that are not working properly, but the easiest one is this mumble server. Here is the setup for it starting with replication controller.
apiVersion: v1
kind: ReplicationController
metadata:
name: mumble-v0
labels:
app: mumble
version: v0
spec:
replicas: 1
selector:
app: mumble
version: v0
template:
metadata:
labels:
app: mumble
version: v0
spec:
containers:
- name: mumble
image: coppit/mumble-server
imagePullPolicy: Always
resources:
limits:
cpu: 0.5
memory: 500Mi
ports:
- containerPort: 64738
name: mumble
- containerPort: 64738
name: mudp
protocol: UDP
And the service itself:
apiVersion: v1
kind: Service
metadata:
name: mumble
labels:
app: mumble
kubernetes.io/name: "mumble"
spec:
selector:
app: mumble
ports:
- name: mumble
port: 64738
- name: mumble-udp
port: 64738
protocol: UDP
externalIPs: ["10.0.1.19"]
Clients are able to connect to the service and see the server, but no voice traffic flows properly. This voice traffic is sent and received via UDP. Looking around, I see other reports of UDP issues that seem to be related Responses from kubernetes containers getting lost and Problems on running a SIP application (UDP) on Kubernetes.
Does anyone know what could be going wrong here or the fix?
If you kubectl get svc
you should see that it either opened the UDP or the TCP port. Kubernetes supporting both UDP and TCP on the same port seems to be an ongoing issue.
If you changed port number, you'd get an error "cannot create an external load balancer with mix protocols" (see related issue).
What you can do is create two services with the same static IP (should be reserved):
apiVersion: v1
kind: Service
metadata:
name: mumble-tcp
labels:
project: mumble
spec:
type: LoadBalancer
loadBalancerIP: 10.10.10.10
ports:
- port: 64738
selector:
name: mumble
project: mumble
---
apiVersion: v1
kind: Service
metadata:
name: mumble-udp
labels:
project: mumble
spec:
type: LoadBalancer
loadBalancerIP: 10.10.10.10
ports:
- port: 64738
protocol: UDP
selector:
name: mumble
project: mumble