Self-hosted service
txn2/kubefwd avatar
txn2/kubefwd

kubefwd: bulk Kubernetes port forwarding with one loopback IP per service

Bulk port forwarding Kubernetes services for local development.

4,170 stars235 forksGoApache-2.0

At a glance

What is it?
kubefwd is a Go CLI that forwards every service in a namespace to your laptop, gives each one a unique 127.x.x.x address, and writes the service names into /etc/hosts. It removes environment-specific connection strings from local development, but it needs sudo and it only forwards services.
Who is it for?
Adopt kubefwd if your local workflow is dominated by service-name connection strings and you want one command per namespace instead of a shell script full of kubectl port-forward calls. Skip it if your blocker is a missing dependency that no service exposes, or if you cannot run a process that edits /etc/hosts and creates loopback interfaces.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The problem is connection strings that only work inside the cluster

An application written for Kubernetes addresses its dependencies by service name. The README gives the shape of it: a database at db:5432, an auth service at auth:443, a cache at redis:6379. Inside the cluster that resolves through DNS. On a laptop it resolves to nothing, so the developer either edits the connection strings for local work or stands up local stand-ins for every dependency. kubefwd's stated goal is to reduce or eliminate that environment-specific connection setup. The target user is a developer running code on a workstation against a shared or personal development cluster, who already has kubectl configured and who is tired of keeping a second set of configuration values in sync with the first. It is not aimed at production traffic, and it is not a service mesh or a traffic shadowing tool. It is a development convenience that makes the laptop look, from the application's point of view, enough like the cluster.

How the forwarding actually works: loopback IPs plus /etc/hosts

The mechanism has four steps, described in the README's How It Works section. kubefwd discovers the services in the namespace you name. It assigns each service its own unique loopback address in the 127.x.x.x range. It writes the service names into /etc/hosts so those names resolve locally. Then it establishes port forwards through the Kubernetes API. The unusual part is the per-service IP. kubectl port-forward binds on localhost and therefore on a single port number, which is why forwarding two services that both listen on 8080 forces you to remap one of them. By giving each service a distinct 127.x.x.x address, kubefwd keeps the original port, so the connection string in your code does not change at all. That is the whole design argument, and it is a coherent one. The README lists auto-reconnect as a feature, which matters because the underlying port-forward streams break when pods restart; the tool re-establishes them rather than making you rerun the command. Around this core, the README also documents an interactive TUI with traffic metrics and pod log streaming, a REST API for programmatic control, and an MCP integration for AI assistants such as Claude Code and Cursor.

Getting it running: install, sudo, and the flags you will actually type

Installation is per-platform. macOS uses brew install kubefwd. Windows has winget install txn2.kubefwd or scoop install kubefwd. Linux users download a .deb, .rpm, or .tar.gz from the releases page. There is also a container image, run with docker run -it --rm --privileged -v "$HOME/.kube:/root/.kube:ro" txn2/kubefwd services -n my-namespace --tui. Note the --privileged flag in that example: the container needs the same elevated capability the binary needs on the host. The normal invocation is sudo -E kubefwd svc -n my-namespace --tui. The -E matters because it carries your environment, including KUBECONFIG, through sudo. The README shows filtering by label with -l app=api and multiple namespaces as a comma-separated list, for example -n default,staging. Adding --api turns on the REST API. In the TUI, ? opens help and q quits. The requirements section is short and worth reading before you install: kubectl configured with cluster access, and root or sudo access for /etc/hosts and network interfaces. The sudo requirement is not incidental. It follows directly from the design, because editing /etc/hosts and creating loopback interfaces are privileged operations.

The sudo requirement and the /etc/hosts edit are the real costs

Two constraints fall out of the architecture. First, kubefwd needs root. That means it cannot run as a background daemon under your normal user account, and it means every invocation is a sudo command whose environment you have to think about. The -E flag in the documented examples exists precisely because of this. Second, it mutates a shared system file. /etc/hosts is global to the machine, so the service names kubefwd writes are visible to every process you run, not just the terminal session that started it. If you are also running a local container that expects a hostname like redis to mean a local container, that name now points at a loopback address owned by kubefwd. The README does not describe a conflict-resolution policy for that case, and the supplied material does not say what happens to /etc/hosts entries if the process is killed rather than exited cleanly. Treat cleanup as something to verify on your own machine before you rely on it. The second limitation is scope: kubefwd forwards services. If your application is blocked on something that is not a Service object, such as a pod you cannot address through a service, a cluster-internal DNS name that is not a service, or a dependency outside the cluster entirely, kubefwd does not cover it. The README's feature list is about forwarding, monitoring and reconnecting, not about intercepting or redirecting traffic.

Where kubefwd sits against Telepresence and mirrord

The README points to a comparison page covering Telepresence and mirrord, and the direction of travel for those tools is different enough to state plainly. kubefwd runs entirely on the client side: it opens port forwards through the Kubernetes API and rewrites /etc/hosts on your laptop. Nothing is installed in the cluster and no workload is modified. The consequence is that your process runs locally and only the connections are tunneled, which is why the tool needs no cluster-side component and why it works against a cluster you do not administer. Telepresence and mirrord take the other approach: they place a component in the cluster so that traffic destined for a workload can be redirected to your machine, which is what allows a service to receive requests as if your local process were the pod. That is a different problem. If you need to receive inbound requests on a service's real cluster address, a client-side forwarder is the wrong shape of tool. If you only need outbound connections to resolve and connect, kubefwd's model is simpler because there is nothing to deploy and nothing to clean up in the cluster. The README's own comparison table draws the line against kubectl port-forward on four axes: one service per command versus all in the namespace, localhost only versus a unique IP per service, manual port-conflict management versus none, and no automatic name resolution versus /etc/hosts entries. Those four differences are accurate descriptions of the mechanism, and they are also the entire value proposition.

Maintenance, release cadence and the Apache-2.0 licence

The repository is active rather than archived, with recent releases v1.25.16, v1.25.15 and v1.25.14 spaced roughly a month apart, and the last push date on the default branch is in the same period. The version numbering tracks Kubernetes minor versions, which is a useful signal for upgrade planning: when your cluster moves a minor version, there is likely a matching kubefwd release, and you should read that release's notes rather than assuming the forwarder is version-agnostic. The README's contributing section states that bug fixes, tests and documentation are welcome but feature development is limited to maintainers, so you should not plan on upstreaming a new forwarding mode. On licensing: the project is Apache-2.0, which permits commercial use and modification and includes a patent grant, with the usual requirements around preserving notices and stating changes. Redistributing a modified kubefwd inside a product is a different exercise from running the binary on a workstation, and the licence text is the thing to read rather than a summary. Nothing here is legal advice. The practical maintenance cost for a user is low: one binary, installed through a package manager, upgraded on the same cadence as your cluster. The cost that does not go away is the sudo invocation and the shared /etc/hosts state, both of which are properties of the design rather than bugs waiting to be fixed.

What to check before you make it part of your daily loop

Run it against a namespace you can afford to disturb, with the TUI on, and watch what it does to /etc/hosts before and after. Confirm that the addresses it assigns do not overlap with anything else listening on loopback on your machine, since a collision would be silent until a connection went to the wrong place. Confirm the cleanup behaviour by exiting with q and inspecting the file, then by killing the process and inspecting it again. If you intend to use the REST API, note that it is opt-in behind --api and that the README does not describe its authentication model in the material available here; treat that as something to read up on before exposing it beyond localhost. If you use the MCP integration with an AI assistant, the same question applies to whatever surface the assistant can reach. And if your team standardises on this, the thing that will actually break is not kubefwd but the assumption that every developer's laptop has the same set of service names in /etc/hosts at the same time.

Editorial conclusion

Adopt kubefwd if your local workflow is dominated by service-name connection strings and you want one command per namespace instead of a shell script full of kubectl port-forward calls. Skip it if your blocker is a missing dependency that no service exposes, or if you cannot run a process that edits /etc/hosts and creates loopback interfaces. Before rolling it out to a team, verify three things: that the sudo -E form preserves your KUBECONFIG in your shell, that the 127.x.x.x addresses it picks do not collide with anything else bound on your machine, and that the /etc/hosts entries are cleaned up when you exit rather than after a kill -9.

Official sources

  1. License: Apache-2.0
  2. Project website
  3. README
  4. Releases
  5. txn2/kubefwd on GitHub
Community notes

Community notes