Kubefwd — Bulk Port Forwarding for Kubernetes Services
A command-line tool that bulk-forwards Kubernetes services to your local machine, mapping service DNS names to localhost. Kubefwd lets developers access remote cluster services as if they were running locally.
What it is
Kubefwd is a command-line tool that bulk-forwards Kubernetes services to your local machine and maps their DNS names to localhost. Instead of running kubectl port-forward for each service individually, kubefwd forwards all services in a namespace with a single command. Your local /etc/hosts is updated so you can access services by their Kubernetes DNS names as if they were running locally.
Kubefwd targets developers who work with multiple microservices on a remote Kubernetes cluster and want to run their local code against those services without modifying connection strings.
How it saves time or tokens
Manually port-forwarding each service requires multiple terminal tabs and remembering which local port maps to which service. Kubefwd eliminates this by forwarding all services in a namespace at once and mapping their names to localhost. Your application config uses the same service names in development and production, reducing environment-specific bugs.
How to use
- Install kubefwd:
brew install txn2/tap/kubefwd
- Forward all services in a namespace:
sudo kubefwd svc -n my-namespace
- Access services by their Kubernetes names:
curl http://my-api:8080/health
curl http://my-database:5432
The sudo is required because kubefwd modifies /etc/hosts to add DNS entries.
Example
Forwarding specific services with label selectors:
# Forward only services with a specific label
sudo kubefwd svc -n dev -l app=backend
# Forward services from multiple namespaces
sudo kubefwd svc -n frontend -n backend
# Use a specific kubeconfig context
sudo kubefwd svc -n dev --context=staging-cluster
Once running, your application connects to http://user-service:3000 and the traffic routes to the pod in the cluster.
Related on TokRepo
- AI Tools for DevOps — Kubernetes development and operations tools
- Automation Tools — developer workflow automation
Common pitfalls
- Kubefwd requires root/sudo because it modifies
/etc/hosts; on corporate machines with restricted permissions, this may be blocked - Services with the same name in different namespaces will conflict in
/etc/hosts; use one namespace at a time or label selectors to avoid collisions - Kubefwd forwards to pods, not through Kubernetes service load balancing; if you need to test load balancing behavior, use the cluster directly
Frequently Asked Questions
Kubefwd modifies your /etc/hosts file to map Kubernetes service names to 127.0.0.1. This requires root privileges on macOS and Linux. The hosts entries are cleaned up when kubefwd exits.
kubectl port-forward handles one service at a time on a specified local port. Kubefwd forwards all services in a namespace simultaneously and maps their DNS names to localhost, so no port number management is needed.
Yes. Kubefwd works with any Kubernetes cluster accessible via kubeconfig, including Docker Desktop, minikube, kind, and remote clusters.
Kubefwd primarily supports macOS and Linux. Windows support exists but requires running as Administrator to modify the hosts file. WSL2 is the recommended approach for Windows users.
Kubefwd cleans up all /etc/hosts entries and closes all port-forward connections when it exits. Your hosts file is restored to its original state.
Citations (3)
- Kubefwd GitHub— Kubefwd bulk port forwarding
- Kubernetes Docs— Kubernetes port forwarding documentation
- Kubefwd Docs— Kubefwd usage guide
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.