Getting Started¶
This guide will help you install kubefwd and start forwarding Kubernetes services to your local machine.
Prerequisites¶
Before using kubefwd, ensure you have:
- kubectl configured with access to a Kubernetes cluster
- Root/sudo access (required for modifying
/etc/hostsand creating network interfaces)
Note: kubefwd reads your kubeconfig file (~/.kube/config or KUBECONFIG env var) and connects directly to the Kubernetes API—it does not invoke kubectl.
Installation¶
macOS¶
Using Homebrew:
To upgrade:
Linux¶
Download pre-built packages from the releases page:
Debian/Ubuntu (.deb):
RHEL/CentOS/Fedora (.rpm):
Any Linux (tar.gz):
Windows¶
Download the Windows executable from GitHub Releases:
- Download
kubefwd_Windows_x86_64.zip - Extract
kubefwd.exe - Add to your PATH or run directly
Run as Administrator (required for hosts file access).
Docker¶
Run kubefwd in a privileged container:
docker run -it --rm --privileged --name kubefwd \
-v "$HOME/.kube:/root/.kube" \
txn2/kubefwd services -n my-namespace --tui
Your First Forward¶
Interactive Mode (Recommended)¶
Launch kubefwd with the TUI for real-time monitoring:
You'll see an interactive interface showing: - All services being forwarded - Connection status and traffic metrics - Real-time logs
Press ? for help, q to quit.
Classic Mode¶
For scripting or simpler output:
Press Ctrl+C to stop forwarding.
What Happens When You Run kubefwd¶
-
Service Discovery: kubefwd queries your cluster for services in the specified namespace(s)
-
IP Allocation: Each service gets a unique loopback IP address (e.g.,
127.1.27.1,127.1.27.2) -
Hosts File Update: Service names are added to
/etc/hostspointing to their assigned IPs: -
Port Forwarding: Connections to each IP:port are forwarded to pods backing the service
-
Ready to Use: Access services by name just like in-cluster:
Important Notes¶
Why sudo -E?¶
kubefwd requires root privileges to:
- Modify /etc/hosts
- Create network interface aliases
- Bind to ports below 1024
The -E flag preserves your environment variables, especially KUBECONFIG:
# Correct - preserves KUBECONFIG
sudo -E kubefwd svc -n default --tui
# Wrong - may fail to find cluster config
sudo kubefwd svc -n default --tui
Cleanup¶
When kubefwd exits (via q or Ctrl+C), it automatically:
- Removes /etc/hosts entries it added
- Removes network interface aliases
- Closes all port forward connections
Your original /etc/hosts is backed up to ~/hosts.original.
Next Steps¶
- TUI Guide - Learn the interactive interface
- Configuration - All command line options
- Advanced Usage - Multi-namespace, selectors, port mapping