skip to Main Content

Let’s say:

apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx-private
data:
3389: “demo/rdp:3389”`

will expose a “rdp” service. If we have 10 services which need to be exposed the same way than how can we achieve that?

2

Answers


  1. You will need to edit this configmap with your new port dynamically.

    You could also use Traefik V2, they democratized the TCP/UDP Service through a CRD.

    But both case, you need to edit a manifest on the kube.

    Login or Signup to reply.
  2. As mentioned by nginx ingress docs here: user-guide/exposing-tcp-udp-services

    You need to edit configmap:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: tcp-services
      namespace: ingress-nginx
    data:
      9000: "default/example-0:8080" 👈
      9001: "default/example-1:8080" 👈
      9002: "default/example-2:8080" 👈
    

    And nginx ingress service:

    apiVersion: v1
    kind: Service
    metadata:
      name: ingress-nginx
      namespace: ingress-nginx
      labels:
        app.kubernetes.io/name: ingress-nginx
        app.kubernetes.io/part-of: ingress-nginx
    spec:
      type: LoadBalancer
      ports:
        - name: http
          port: 80
          targetPort: 80
          protocol: TCP
        - name: https
          port: 443
          targetPort: 443
          protocol: TCP
        - name: proxied-tcp-9000  👈
          port: 9000
          targetPort: 9000
          protocol: TCP
        - name: proxied-tcp-9001  👈
          port: 9001
          targetPort: 9001
          protocol: TCP
        - name: proxied-tcp-9002  👈
          port: 9002
          targetPort: 9002
          protocol: TCP
      selector:
        app.kubernetes.io/name: ingress-nginx
        app.kubernetes.io/part-of: ingress-nginx
    

    And you can add as many ports as you’d like. Just remeber that one port can only be used once.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search