kubernetes – How to set up RTMP protocol in Ingress Nginx?
RTMP is a TCP-based protocol and standard Ingress does not support TCP services.
The NGINX Ingress controller (which it looks like you are using) can be configured to expose TCP services.
First, you’ll need to make sure that you expose both the HTTP and RTMP ports in your stream-server-srv
Service:
apiVersion: v1
kind: Service
metadata:
name: stream-server-srv
namespace: default
spec:
selector:
app: stream-server
type: ClusterIP
ports:
- name: http-port
port: 8000
targetPort: 8000
protocol: TCP
- name: rtmp-port
port: 1935
targetPort: 1935
protocol: TCP
(replace default with your namespace)
You will also need to make sure that the Service used to expose the NGINX ingress exposes port 1935 as well. For example:
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: 1.2.0
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
externalTrafficPolicy: Local
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- appProtocol: http
name: http
port: 80
protocol: TCP
targetPort: http
- appProtocol: https
name: https
port: 443
protocol: TCP
targetPort: https
- name: rtmp
port: 1935
protocol: TCP
targetPort: 1935
selector:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
type: LoadBalancer
Finally, you’ll need to update / patch the NGINX tcp services ConfigMap:
kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"1935":"default/stream-server-srv:1935"}}'
(replace “default/stream-server-srv” with your namespace/servicename)
Read more here: Source link