<p>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  </p>

<pre><code>+-----------+    +--------+     +-----------+
|           |    |        |     |           |
| Localhost +--&gt; |  Pod   +---&gt; |  AWS RDS  |
|           |    |        |     |           |
+-----------+    +--------+     +-----------+
</code></pre>

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

<pre><code>ssh -L 5432:test.rds.amazonaws.com:5432 name-of-host
</code></pre>

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

<pre><code>kubectl port-forward pod-name 5432:5432
</code></pre>

<p>Anyone knows how to tackle this issue?</p>

<p>What you refer to is ssh port forwarding, and kubernetes has something similar with <code>kubectl port-forward &lt;mypod&gt; &lt;localport&gt;:&lt;podport&gt;</code>. 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.</p>
