<p>I have multiple deployments running of RDP application and they all are exposed with ClusterIP service. I have nginx-ingress controller in my k8s cluster and to allow tcp I have added <code>--tcp-services-configmap</code> flag in nginx-ingress controller deployment and also created a configmap for the same that is shown below</p>
<pre><code>apiVersion: v1 
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
  3389: “demo/rdp-service1:3389”
</code></pre>
<p>This will expose “rdp-service1” service. And I have 10 more such services which needed to be exposed on the same port number but if I add more service in the same configmap like this</p>
<pre><code>...
data
  3389: “demo/rdp-service1:3389”
  3389: “demo/rdp-service2:3389”
</code></pre>
<p>Then it will remove the previous service data and since here I have also deployed external-dns in k8s, so all the records created by ingress using <code>host: ...</code> will starts pointing to the deployment attached with the newly added service in configmap.</p>
<p>Now my final requirement is as soon as I append the rule for a newly created deployment(RDP application) in the ingress then it starts allowing the TCP connection for that, so is there any way to achieve this. Or is there any other Ingress controller available that can solve such type of use case and can also easily be integrated with external-dns ?</p>
<p>Note:- I am using AWS EKS Cluster and Route53 with external-dns.</p>

Ajay Pathak
<p>Posting this answer as a community wiki to explain some of the topics in the question as well as hopefully point to the solution.</p>
<p>Feel free to expand/edit it.</p>
<hr />
<p><code>NGINX Ingress</code> main responsibility is to forward the <strong><code>HTTP</code></strong>/<strong><code>HTTPS</code></strong> traffic. With the addition of the <code>tcp-services</code>/<code>udp-services</code> it can also forward the <code>TCP</code>/<code>UDP</code> traffic to their respective endpoints:</p>
<ul>
<li><em><a href="https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/" rel="nofollow noreferrer">Kubernetes.github.io: Ingress nginx: User guide: Exposing tcp udp services</a></em></li>
</ul>
<p>The main issue is that the <code>Host</code> based routing for <code>Ingress</code> resource in Kubernetes is targeting specifically <code>HTTP</code>/<code>HTTPS</code> traffic and not <code>TCP</code> (<code>RDP</code>).</p>
<p>You could achieve a following scenario:</p>
<ul>
<li><code>Ingress controller</code>:
<ul>
<li><code>3389</code> - <code>RDP</code> <code>Deployment</code> #1</li>
<li><code>3390</code> - <code>RDP</code> <code>Deployment</code> #2</li>
<li><code>3391</code> - <code>RDP</code> <code>Deployment</code> #3</li>
</ul>
</li>
</ul>
<p>Where there would be no <code>Host</code> based routing. It would be more like port-forwarding.</p>
<blockquote>
<p>A side note!
This setup would also depend on the ability of the <code>LoadBalancer</code> to allocate ports (which could be limited due to cloud provider specification)</p>
</blockquote>
<hr />
<p>As for possible solution which could be not so straight-forward I would take a look on following resources:</p>
<ul>
<li><em><a href="https://stackoverflow.com/questions/34741571/nginx-tcp-forwarding-based-on-hostname">Stackoverflow.com: Questions: Nxing TCP forwarding based on hostname</a></em></li>
<li><em><a href="https://doc.traefik.io/traefik/routing/routers/#configuring-tcp-routers" rel="nofollow noreferrer">Doc.traefik.io: Traefik: Routing: Routers: Configuring TCP routers</a></em></li>
<li><em><a href="https://github.com/bolkedebruin/rdpgw" rel="nofollow noreferrer">Github.com: Bolkedebruin: Rdpgw</a></em></li>
</ul>
<p>I'd also check following links:</p>
<ul>
<li><p><em><a href="https://aws.amazon.com/quickstart/architecture/rd-gateway/" rel="nofollow noreferrer">Aws.amazon.con: Quickstart: Architecture: Rd gateway</a></em> - AWS specific</p>
</li>
<li><p><em><a href="https://docs.konghq.com/kubernetes-ingress-controller/1.2.x/guides/using-tcpingress/" rel="nofollow noreferrer">Docs.konghq.com: Kubernetes ingress controller: 1.2.X: Guides: Using tcpingress</a></em></p>
</li>
<li><p>Haproxy:</p>
<ul>
<li><em><a href="https://www.haproxy.com/documentation/aloha/12-0/deployment-guides/remote-desktop/rdp-gateway/" rel="nofollow noreferrer">Haproxy.com: Documentation: Aloha: 12-0: Deployment guides: Remote desktop: RDP gateway</a></em></li>
<li><em><a href="https://www.haproxy.com/documentation/aloha/10-5/deployment-guides/remote-desktop/" rel="nofollow noreferrer">Haproxy.com: Documentation: Aloha: 10-5: Deployment guides: Remote desktop</a></em></li>
<li><em><a href="https://www.haproxy.com/blog/microsoft-remote-desktop-services-rds-load-balancing-and-protection/" rel="nofollow noreferrer">Haproxy.com: Blog: Microsoft remote desktop services rds load balancing and protection</a></em></li>
</ul>
</li>
</ul>
