DEV Community

Cover image for This Little kubernetes Port Forwarder Helped me to Save a lot of Time and Headache
donnercody | Thoren
donnercody | Thoren

Posted on

This Little kubernetes Port Forwarder Helped me to Save a lot of Time and Headache

I have built open-source kubelinkr to get connected to different kubernetes systems with one click — it saves me a lot of time.

When you are a web developer or full-stack developer, you need to test and debug systems daily. So in my case, I have more than 10 kubernetes systems that I use for developing different projects.

Sometimes I need to connect to databases from my local machine directly to a kubernetes, other times I only need to access an application inside kubernetes without being publicly available.

Image of kubelinkr structure

Before I developed kubelinkr I switched between the kubernetes by changing the “current-context” inside the config and then each time connecting and disconnecting via the terminal. After 10x a day — it was annoying.

But why not use Kubeforwarder?

I know some of you would argue, “But there is kubeforwarder” doing the same. Yeah, but I tried kubeforwarder for MySQL and MongoDB port forwarding. In both cases, I got a lot of connection drops and that's very bad for my applications.

That's why I built kubelinkr — and for me, it's doing a great job so far.

How to download kubelinkr

You can download kubelinkr for free on my GitHub:
GitHub - donnercody/kubelinkr: A Menubar One-Click Application for Kubernetes forwarding multiple…

Please check it out and give me some feedback.

How to use kubelinkr

After you have downloaded and installed kubelinkr it will show a small icon in your tray.

When you click on that Icon, you will see Dialog where you can now connect to your different projects.

Click on the play or stop buttons to connect to different kubernetes.

When you click on “Play” on any of the projects in the image above, you can directly start the port forwardings and access your systems by “localhost:yourport” on your local machine. By pressing “stop” all your port forwards stop immediately.

How to configure kubelinkr

First: The configuration for kubelinkr is your kube config file in your directory: “~/.kube/config”.

When you open kubelinkr for the first time, it will look like this:

add new project in kubelinkr

To create a new project click on “Add New Project”.

What is a project

For my purposes, a project is a set of different port-forwards to one or multiple kubernetes. I want to start, stop, and switch between different projects, so I can quickly test and validate.

I also use different “stages” for different projects. (project-a test and project-a live are different projects with the same port forward logic on different kubernetes).

Create a project

Now you enter any name inside the Dialog and click on Create.

Create a new project (kubelinkr)

After that, you can now create your port forwards on that project. Expand the created project and click on “Create new Port Forward”.

Create a new port forwarding for your project (kubelinkr)

Now your kubernetes config comes into play. You select the kubernetes system you want to create a port forward to.

select your namespace | kubelinkr

Then select your namespace, the pods you want to connect are inside.

select the target pod  | kubelinkr

After this step, you can select the target pod.

modify ports  | kubelinkr

In the next step, you enter your local and remote ports.

modify remote ports | kubelinkr

Then you click “Create” on the Dialog:

create the project  | kubelinkr

Showing the port forwards in your created project.

Finished — now you can press “Play” to connect to your project in kubernetes and port forward any pod to your local machine.

Do you want your own cheap kubernetes?

Here is another story that may be interesting for you.
Host an On-Premise Kubernetes Cloud Using Hetzner and Save a lot of Money. (NFS, Metrics and More)

Thanks for reading,

Thoren

Top comments (0)