<p>I have a Kubernetes cluster set up on Google Kubernetes Engine. I have a pod that hosts an RTMP application. This application requires two ports, one for HTTP and one for RTMP. I have set up an ingress Nginx load balancer. It routes the HTTP traffic correctly. I want to be able to route the RTMP traffic as well. But when I write RTMP in my YAML file. It shows it as an unknown field. I am using skaffold and Google Cloud Build to deploy.</p>
<p>Here is the Ingress-srv file</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  rules:
    - http:
        paths:
          - path: /?(.*)
            backend:
              serviceName: stream-server-srv
              servicePort: 8000
</code></pre>
<p>What I want to be able to do is have an entry for RTMP on port 1935. That I can then use to stream love videos using RTMP protocol.</p>

<p>RTMP is a TCP-based protocol and standard Ingress does not support TCP services.</p>
<p>The NGINX Ingress controller (which it looks like you are using) can <a href="https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/" rel="nofollow noreferrer">be configured to expose TCP services</a>.</p>
<p>First, you'll need to make sure that you expose both the HTTP and RTMP ports in your <code>stream-server-srv</code> Service:</p>
<pre><code>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
</code></pre>
<p>(replace default with your namespace)</p>
<p>You will also need to make sure that the <a href="https://github.com/kubernetes/ingress-nginx/blob/main/deploy/static/provider/cloud/1.23/deploy.yaml#L313" rel="nofollow noreferrer">Service used to expose the NGINX ingress</a> exposes port 1935 as well.  For example:</p>
<pre><code>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
</code></pre>
<p>Finally, you'll need to update / patch the NGINX tcp services ConfigMap:</p>
<pre><code>kubectl patch configmap tcp-services -n ingress-nginx --patch '{&quot;data&quot;:{&quot;1935&quot;:&quot;default/stream-server-srv:1935&quot;}}'
</code></pre>
<p>(replace &quot;default/stream-server-srv&quot; with your namespace/servicename)</p>
