QGA
QGA

Reputation: 3192

How can I proxy forward traffic using kubernetes

Does anyone know how could I proxy forward database traffic from localhost to an AWS database using kubernetes. Networkingwise, the pod has access to the db and it looks like below

+-----------+    +--------+     +-----------+
|           |    |        |     |           |
| Localhost +--> |  Pod   +---> |  AWS RDS  |
|           |    |        |     |           |
+-----------+    +--------+     +-----------+

If I had a normal ubuntu box instead of a pod I would have done something like this

ssh -L 5432:test.rds.amazonaws.com:5432 name-of-host

I tried to run the command below but that only proxy port 5432 to the pod not to RDS

kubectl port-forward pod-name 5432:5432

Anyone knows how to tackle this issue?

Upvotes: 1

Views: 1010

Answers (1)

What you refer to is ssh port forwarding, and kubernetes has something similar with kubectl port-forward <mypod> <localport>:<podport>. With one crucial difference, it forwards just the ports from the pod you point it to. What we do to achieve more or less what you ask for, is running an HAProxy in a pod. Then you can port-forward to proxying service running in pod and HAProxy will pass your traffic to the RDS.

Upvotes: 1

Related Questions