Git Product home page Git Product logo

autoportforward's Introduction

Auto-portforward (apf)

A handy tool to automatically set up proxies that expose the remote container's listening ports back to the local machine. Just like kubectl portforward or docker run -p LOCAL:REMOTE, but automatically discover and update the ports to be forwarded on the fly.

I often find myself forgot to add -p option when testing a image with docker, or missed to expose some other ports. Now I don't need to worry about that, I just run the following commands:

$ docker run -d --name redis redis

$ apf redis

*  ==> : Forwarding local listening ports to (==>) remote ports
*  <== : Forwarding to local ports from (<==) remote listening ports (use -r option)

Forwarding: [6379 ==> 6379]

apf will update the port list on the fly. So if you login to the container and start other server listening on different ports, it will dynamically update the local listeners.

For kubernetes:

$ kubectl run --image redis redis

$ apf -k default/redis
Forwarding: [6379 ==> 6379]

Installation

First of all, apf requires a working docker / kubectl client setup, the client can conect to either local docker daemon / k8s cluster or remote.

You can either download the binary from the release artifacts or build it yourself.

# MacOS (Intel)
curl -L -O https://github.com/ruoshan/autoportforward/releases/download/v0.0.3/apf-mac
chmod +x apf-mac
mv apf-mac /usr/local/bin/apf

# Linux
curl -L -O https://github.com/ruoshan/autoportforward/releases/download/v0.0.3/apf-linux-x64
chmod +x apf-linux-x64
mv apf-linux-x64 /usr/local/bin/apf

To manually build it, clone the repo and run the build.sh script.

Usage

Expose all the listening ports in the container back to the local machine

# Docker
apf {container ID / name}

# Kubernetes
apf -k {namespace}/{pod name}

Also expose local ports (8080,9090) to the container

# Docker
apf -r 8080,9090  {container ID / name}

# Kubernetes
apf -r 8080,9090 -k {namespace}/{pod name}

autoportforward's People

Contributors

l4zy0n3 avatar ruoshan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.