Kubernetes with cloud providers - How to route SSH trafic to services with Loadbalancers

2/23/2022

I'm trying to build a Kubernetes cluster to allow multi-website testing, with multiple databases engine, multiple php versions, multiple dependancies, multiple front-end stacks, ...

So, my goal is to build something similar to this :

infrastructure schema

When using ingress-nginx, my cloud provider gives me a LoadBalancer IP.

I was able to deploy ingress-nginx to route my http/https trafic to the right service using ingress host rules.

Now, i want to be able to connect via SSH to the project1_ssh service with the loadbalancer ip, on port 2022, and to project2_ssh service with the same loadbalancer ip, on port 2023.

Can i achieve that ? I'm note sure ingress-nginx will allow me to do that.

I successfully was able to connect to my ssh service declaring this kind of service :

kind: Service
apiVersion: v1
metadata:
  name: ssh-service
spec:
  selector:
    app: project1
  ports:
    - port: 2300
      targetPort: 23
  type: LoadBalancer

But doing this, creates a new loadbalancerIp, and a new bill on the cloud provider.

I want to have only one LoadBalancer service.

Any suggestions ?

The idea is to run ~50 websites, each one in a pod.

-- Thomas
kubernetes
kubernetes-ingress
nginx-ingress
traefik

1 Answer

2/23/2022

Ok, i finally removed ingress-nginx, and switched to Traefik-V2, and i achieved what i wanted.


Now i will try to figure out if SNI can make it even more simple (one same port for all my ssh services, but the host called in my ssh request would be used to route the connection to the right service inside the cluster.

https://kupczynski.info/2019/05/21/traefik-sni.html

Will let you know if it finally works

-- Thomas
Source: StackOverflow