l7mp / stunner

A Kubernetes media gateway for WebRTC. Contact: info@l7mp.io
https://l7mp.io
MIT License
737 stars 56 forks source link

Issue UDP port loadbalancer #116

Closed gabrielmatau79 closed 7 months ago

gabrielmatau79 commented 9 months ago

Hello!

I'm trying to install stunner on my kubernetes but i seeing that UPD service on my loadbalancer no found , Did anyone have this problem, how did you solve it?

kubectl describe svc udp-gateway -n stunner-system
Name:                     udp-gateway
Namespace:                stunner-system
Labels:                   stunner.l7mp.io/owned-by=stunner
                          stunner.l7mp.io/related-gateway-name=udp-gateway
                          stunner.l7mp.io/related-gateway-namespace=stunner-system
Annotations:              stunner.l7mp.io/related-gateway-name: stunner-system/udp-gateway
Selector:                 app=stunner,stunner.l7mp.io/related-gateway-name=udp-gateway,stunner.l7mp.io/related-gateway-namespace=stunner-system
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.3.156.74
IPs:                      10.3.156.74
Port:                     udp-listener  3478/UDP
TargetPort:               3478/UDP
NodePort:                 udp-listener  31325/UDP
Endpoints:                10.2.0.75:3478
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type     Reason                  Age                   From                Message
  ----     ------                  ----                  ----                -------
  Warning  SyncLoadBalancerFailed  22m (x19 over 88m)    service-controller  Error syncing load balancer: failed to ensure load balancer: only TCP protocol is supported, got: "UDP"
  Normal   EnsuringLoadBalancer    2m47s (x23 over 88m)  service-controller  Ensuring load balancer
rg0now commented 9 months ago

Unfortunately, this sometimes happens with certain cloud providers. Which provider are you using? Note that STUNner can fall back to NodePort if UDP load-balancing is not available, did you try this?

gabrielmatau79 commented 9 months ago

Unfortunately, this sometimes happens with certain cloud providers. Which provider are you using? Note that STUNner can fall back to NodePort if UDP load-balancing is not available, did you try this?

Thanks for you response mate @levaitamas, i don't try because stunner make a work by himself create service, you can help me with some guide about this... Thank you in advance for your assistance

levaitamas commented 9 months ago

Check the generated services. LoadBalancer services are exposed via a NodePort (tipically in the range of 30000-32767) too. You can use this port to connect. Here is a short summary on how to get the nodeport of a lb service: https://sysdig.com/blog/kubernetes-services-clusterip-nodeport-loadbalancer/

Still interested in that which cloud provider are you using? Some providers require some extra annotations for UDP-based LB services. Hopefully, this trick can work in your setup too.

gabrielmatau79 commented 9 months ago

Check the generated services. LoadBalancer services are exposed via a NodePort (tipically in the range of 30000-32767) too. You can use this port to connect. Here is a short summary on how to get the nodeport of a lb service: https://sysdig.com/blog/kubernetes-services-clusterip-nodeport-loadbalancer/

Still interested in that which cloud provider are you using? Some providers require some extra annotations for UDP-based LB services. Hopefully, this trick can work in your setup too.

Thank you @levaitamas i check and tell you ...

gtokarz commented 8 months ago

I have solved that on provider which did not support udp for mnaged loadbalancers but allowed that for manually added loadbalancers (openstack based provider), used such config

---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: media-gateway
  namespace: {{ .Release.Namespace }}
  annotations:
    stunner.l7mp.io/service-type: NodePort
spec:
  gatewayClassName: stunner-gatewayclass
  addresses:
    - type: IPAddress
      value: **MANUAL.LB.ADDRESS.X**
  listeners:
    - name: udp-listener
      port: 3478
      protocol: TURN-UDP
---
# stunner will look for existing service and extend/use it
apiVersion: v1
kind: Service
metadata:
  name: media-gateway
  namespace: {{ .Release.Namespace }}
spec:
  selector:
    app: stunner
  ports:
    - port: 3478
      nodePort: 30478
      protocol: UDP
      targetPort: 3478
      name: udp-listener
  type: NodePort

Then i have used some terraform to spin up manual loadbalancer pointing such UDP node service (External LoadBalancer => <nodeIp>:<nodePort>), uggly but works

juber-nunes commented 7 months ago

I'm also facing the same issue on AWS. Have not yet tried @gtokarz approach, hoping that works.

rg0now commented 7 months ago

Closing this for now. Feel free to reopen is something comes up.