Also at Deasil Works · txn2 · Plexara
Profiles GitHub · X · LinkedIn
Theme Light · Auto · Dark
Professional notes by Craig Johnston
long-form, short-form, working drafts · since 2008
VOL. XIX · MMXXVI
82 NOTES IN PRINT
FOLIO LXXII 04 JAN 2026 · 2 MIN · SHORT-FORM

kubefwd: Forward Kubernetes Services to Localhost by Name

One command, no configuration, automatic reconnection

Diagram · folio lxxii
flowchart TB
  APP(["Your App"])
  APP -->|"postgres:5432"| HOSTS
  HOSTS["/etc/hosts entry"]
  HOSTS -->|"127.1.27.1:5432"| KFWD
  KFWD{{"kubefwd listener"}}
  KFWD -->|"port-forward channel"| KAPI
  KAPI["kubectl port-forward"]
  KAPI -->|"TCP to pod IP"| POD
  POD[("postgres pod in cluster")]

kubectl port-forward works fine for one service. Two services? Three? A microservices app with a dozen dependencies? You end up with a terminal full of port-forward commands, each needing different local ports to avoid conflicts, and connection strings that differ between local and production.

§The Solution

kubefwd bulk-forwards Kubernetes services so they’re accessible by their real hostnames:

brew install txn2/tap/kubefwd
sudo -E kubefwd svc -n mynamespace

Your app connects to postgres:5432 and redis:6379 locally, using the same hostnames it would use inside the cluster.

§How It Works

Your App → postgres:5432
         → /etc/hosts: postgres = 127.1.27.1
         → kubefwd listens on 127.1.27.1:5432
         → forwards to pod in Kubernetes cluster

kubefwd creates unique loopback IPs for each service (127.1.27.1, 127.1.27.2, …) so multiple services can use the same port. It adds entries to /etc/hosts and cleans them up on exit.

§Why Sudo?

kubefwd modifies /etc/hosts and binds to loopback addresses. Both require root on Unix systems. Unlike kubectl port-forward which uses unprivileged high ports, kubefwd preserves the real service ports so your configuration matches production.

All modifications are temporary. kubefwd removes /etc/hosts entries and releases network bindings when it exits.

§New in 2026

  • Auto-reconnect: Survives pod restarts, deployments, VPN drops, and laptop sleep/wake
  • Interactive TUI: Browse namespaces, forward services, view pod logs (--tui)
  • REST API: 40+ endpoints for programmatic control
  • MCP server: AI assistants can manage forwarding

Full feature guide

§vs. Telepresence

Different tools for different problems:

  • kubefwd: Local app connects to cluster services. Traffic flows local → cluster. Simple.
  • Telepresence: Cluster traffic routes to your local machine. Traffic interception, preview URLs, debugging with real traffic.

kubefwd is one binary, one command, no cluster components. Telepresence does more, but requires more. Choose based on what you need.

§Install

macOS: brew install txn2/tap/kubefwd

Linux: Download from releases

Windows: scoop install kubefwd

§Links

← back to all notes