This Little kubernetes Port Forwarder Helped me to Save a lot of Time and Headache
Published: 2024-05-08 14:48:32


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](https://cdn-images-1.medium.com/max/2000/1*EACREt5YIGOZcGuAUH4ojQ.png)

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](https://kube-forwarder.pixelpoint.io/)” 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…**](https://github.com/donnercody/kubelinkr)
>  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.](https://cdn-images-1.medium.com/max/2038/1*ghMT6SAu3g-CWHCrpPMy3Q.png)

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](https://cdn-images-1.medium.com/max/2000/1*CpqgOt4ZuDL1nHXbGSNJKA.png)

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)](https://cdn-images-1.medium.com/max/2000/1*sNNu8hV8CYavxQ16S9Oc_A.png)

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)](https://cdn-images-1.medium.com/max/2000/1*--fzVnmhJycJc09GA_EwKw.png)

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

![select your namespace | kubelinkr](https://cdn-images-1.medium.com/max/2000/1*n2uMR8Js5fG9x-9aEWafPg.png)

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

![select the target pod  | kubelinkr](https://cdn-images-1.medium.com/max/2000/1*yn1UFlcyEhBlqe1VD1_TKA.png)

After this step, you can select the target pod.

![modify ports  | kubelinkr](https://cdn-images-1.medium.com/max/2000/1*B-RXuoc1GMhNZkDFCbcb8Q.png)

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

![modify remote ports | kubelinkr](https://cdn-images-1.medium.com/max/2000/1*eAoYEG8nytlkfY9Se4D1rQ.png)

Then you click “Create” on the Dialog:

![create the project  | kubelinkr](https://cdn-images-1.medium.com/max/2034/1*b3gc7hrfKXZd8ONYohxMpw.png)

![Showing the port forwards in your created project.](https://cdn-images-1.medium.com/max/2000/1*EJ-QgizBvupWnGrFaTBysA.png)
>  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)**](https://medium.com/@thoren.lederer/host-a-on-premise-kubernetes-cloud-using-hetzner-and-save-a-lot-of-money-nfs-metrics-and-more-157f467d7977)

Thanks for reading,

Thoren