I have a Kubernetes Cluster with a NGINX Ingress Controller. In the cluster I have deployed a Gitea POD. The Web UI and the HTTPS access is exposed via an Ingress object like this one:
---
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: "letsencrypt-prod"
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
This works all fine for HTTPS.
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?
As far as I understand I should patch my NGINX controller deployment with something like that:
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
and providing a config map pointing to my gitea service:
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-configmap-giteassh
namespace: ingress-nginx
data:
22: "gitea-repo/gitea-service:22"
Do I need also an additional Ingress configuration in my Gitea POD now?
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?