nginx-ingress-controller serving SSH Port

· 133 words · 1 minute read

To be able to use ssh with for example Gitea in Kubernetes an additional port needs to be exposed. I normally use port 2222 as the ssh port for Git. In the standard configuration nginx-ingress-controller only serves ports 80 (HTTP) and 443 (HTTPS). It would be possible to expose the port with a seperate load balancer service but this would mean a different hostname to access the load balancer service too.

To use the nginx-ingress-controller load balancer it is possible to add custom TCP and UDP services/ports to nginx-ingress-controller through ConfigMaps.

When using Helm to install nginx-ingress-controller it is as easy as adding the following configs to values.yaml:

  2222: "gitea/gitea-helm-ssh:2222"

The config explained:

  <exposed-port>: "<service-namespace>/<service-name>:<service-port>"

This basically exposed the service gitea-helm-ssh in the gitea namespace with port 2222 through TCP port 2222.