title: How to expose port 22 via NGINX Ingress Controller?
body: <p>I have a Kubernetes Cluster with a NGINX Ingress Controller. In the cluster I have deployed a <a href="https://gitea.io/" rel="nofollow noreferrer">Gitea</a> POD. The Web UI and the HTTPS access is exposed via an Ingress object like this one:</p>
  <pre><code>---
  kind: Service
  apiVersion: v1
  metadata:
    name: gitea-service
    namespace: gitea-repo
  spec:
    selector:
      app: gitea
    ports:
    - name: gitea-http
      port: 3000
    - name: gitea-ssh
      port: 22
  ---
  kind: Ingress
  apiVersion: networking.k8s.io/v1
  metadata:
    name: git-tls
    namespace: gitea-repo
    annotations:
      cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;
  spec:
    tls:
    - hosts:
      - git.foo.com
      secretName: tls-gitea
    rules:
    - host: git.foo.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: gitea-service
              port:
                number: 3000
  </code></pre>
  <p>This works all fine for HTTPS.</p>
  <p>But Gitea also provides a SSH access through port 22. My Question is, how can I tell the NGINX Ingress Controller to route also port 22 to my pod?</p>
  <p>As far as I understand I should patch my NGINX controller deployment with something like that:</p>
  <pre><code>spec:
    template:
      spec:
        containers:
        - name: controller
          # defind cusotm tcp/udp configmap
          args:
          - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-configmap-giteassh
  
          ports:
           - name: ssh
             containerPort: 22
             protocol: TCP
  </code></pre>
  <p>and providing a config map pointing to my gitea service:</p>
  <pre><code>apiVersion: v1
  kind: ConfigMap
  metadata:
    name: tcp-configmap-giteassh
    namespace: ingress-nginx
  data:
    22: &quot;gitea-repo/gitea-service:22&quot;
  </code></pre>
  <p>Do I need also an additional Ingress configuration in my Gitea POD now?</p>
  <p>I wonder if this is the correct approach. Why I am forced to define this in the NGINX controller and not in my POD namespace as I do for HTTP? This would mean that for each POD exposing a TCP port other than HTTP I have to adjust my Ingress NGINX Controller?</p>