Skip to content

mattlord/docker-port-fwdr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

docker-port-fwdr

Creates a simple container image for port forwarding.

This can, for example, serve as a sort of jump host when accessing cloud services through a k8s cluster from your local machine. Here's an example for MySQL admins (at this point you will have already connected and auth'd with your k8s cluster):

# run the port forwarder pod in your k8s cluster
$ kubectl run -it --rm -n <namespace> --image=mattalord/port-fwdr --restart=Never port-fwdr 3306 <cloud endpoint>:3306

# forward your local port to the new relay pod
$ kubectl port-forward -n <namespace> pod/port-fwdr 3306:3306 &

Then you can use your favorite MySQL client, e.g. MySQL Workbench, on your local machine to access the remote database instance (e.g. RDS) using TLS.

If you need an SSL tunnel between the pod and the endpoint -- for example when using the redis-cli to connect to a TLS enabled Cloud Redis service such as ElastiCache -- then you can add an optional third parameter of "stunnel":

$ kubectl run -it --rm -n $NAMESPACE --image=mattalord/port-fwdr --restart=Never redis-port-fwdr 6379 <cloud endpoint>:6379 stunnel
$ kubectl port-forward -n $NAMESPACE pod/redis-port-fwdr 6379:6379

Then you can use the local redis client to connect to the TLS'd redis service. For example:

$ redis-cli
127.0.0.1:6379> AUTH <auth token>
OK
127.0.0.1:6379> set mytest "hi"
OK
127.0.0.1:6379> get mytest
"hi"
127.0.0.1:6379> del mytest
(integer) 1

About

A simple container image for port forwarding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published