Develop k8s apps in your local environment, with full connectivity to and from remote k8s resources.
It's like stuffing your laptop inside a k8s pod.
- Install and configure
kubectl
locally, so that remote commands can be run from your local environment. - Install sshuttle and
socat
brew install sshuttle socat
(OSX)
or
apt-get install sshuttle socat
(debian linux) - Run
./connect.sh
on your laptop.
(You should now be able to connect to k8s resources by IP & by DNS name.) - Run
./redirect.sh [--namespace=<namespace>] <service ...>
(Any program that connects to the specified service(s) should now be redirected to your machine.)
That's it!
- Run
./redirect.sh --revert [--namespace=<namespace>] <service ...>
or
./redirect.sh --revert-all
. Ctrl-C
the./connect.sh
process.
- Only fully-qualified k8s DNS names will be resolved by the k8s DNS service (must end in
*.cluster.local
). - Only TCP traffic is supported.
./connect.sh
must be running (and remain running) in order for./redirect.sh
to function.
Proxy pods are deployed into the k8s environment (on-demand, typically one per namespace).
Outgoing TCP traffic:
In the local environment, any traffic that has a destination in the k8s subnet range, is sent to the proxy pod by sshuttle.
Outgoing DNS traffic:
Any DNS requests with an address ending in *.cluster.local
is sent to the proxy pod, and then is forwarded from there on to the k8s DNS service.
Incoming TCP traffic:
A service's traffic is redirected to the proxy pod by; the pod then forwards it to the local environment using ssh port forwarding.