From d14b718f13f1038a340905538b535dc8b268ad2e Mon Sep 17 00:00:00 2001 From: Ryan Kraus Date: Sun, 29 Jan 2023 15:34:43 -0500 Subject: [PATCH] Adding a kubectl plugin --- kubectl-kuttle | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 kubectl-kuttle diff --git a/kubectl-kuttle b/kubectl-kuttle new file mode 100644 index 0000000..3301176 --- /dev/null +++ b/kubectl-kuttle @@ -0,0 +1,20 @@ +#!/bin/bash + +# start the sshuttle tunnel +if [[ $1 == "start" ]]; then +mkdir -p ~/.cache +kubectl run kuttle --image=alpine:latest --restart=Never -- sh -c 'apk add python3 --update && exec tail -f /dev/null' +sshuttle --remote kuttle --dns --daemon --pidfile ~/.cache/kuttle.pid --auto-hosts --ssh-cmd kuttle 0.0.0.0/0 +exit 0 +fi + +# stop the sshuttle tunnel +if [[ $1 == "stop" ]]; then +kill `cat ~/.cache/kuttle.pid`; +kubectl delete pod/kuttle --force +exit 0 +fi + +# help docs +echo "kubectl kuttle [start/stop]" +exit 1