fwd
fwd copied to clipboard
Bulk port-forwarding for kubectl
fwd
kubectl port-forward with multiple targets and auto-recovery.
Usage
go get -u github.com/adamglt/fwd or download a binary from the releases tab.
Here's an example of a multi-context multi-namespace forwarding config.
fwd uses $HOME/.fwd.yaml by default, you can supply a different file using fwd -c <path>.
cidr: 127.0.15.1/24 # local cidr - defaults to 127.0.11.0/24
contexts:
- name: prod-cluster # empty name defaults to $(kubectl config current-context)
namespaces:
- name: prod-ns-1
services:
- name: svc1
- name: svc2
- name: minikube
namespaces:
- name: ns1
services:
- name: svc1
- name: svc2
- name: ns2
services:
- name: svc1
- name: svc2
aliases:
- short1
- short2
fwd proxies calls to kubectl port-forward svc/<...> for every port the service exposes.
The endpoints are then made available using their local names (<svc>.<namespace>:<port>) and global names (<svc>.<namespace>.<context>:<port>).
When the local name exists in more than one context, only the global name is made available.
Service entries may also include short global aliases to make access easier - in the example above, svc2.ns2:<port> will also be exposed at short1:<port> and short2:<port>.
fwd is very similar to the popular https://github.com/txn2/kubefwd in concept, with three major differences:
- it is config-based and not flag-based
- it natively supports multiple contexts (for teams working with more than one cluster)
- it uses a simple but effective per-connection error recovery
Requirements
fwduseskubectlfor actual forwarding, so that's required.- Only Linux and macOS are supported at the moment (PRs welcome).
sudois required - the tool has to modify/etc/hostsfor the local/global names to be resolvable.
In macOS we also have to create aliases forlo0(both are cleaned up on exit).
License
MIT