Skip to content

Instantly share code, notes, and snippets.

@afbjorklund
Created June 15, 2022 10:57
Show Gist options
  • Save afbjorklund/334ff06cc38093f1bb6fc97446b14ed4 to your computer and use it in GitHub Desktop.
Save afbjorklund/334ff06cc38093f1bb6fc97446b14ed4 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Wrapper for using kubectl as "ssh", for rsync and git
# - setting either $RSYNC_RSH or $GIT_SSH env variables
namespace=''
pod=$1
shift
# POD[@NAMESPACE]:DEST
if [ "X$pod" = "X-l" ]; then
pod=$1
shift
namespace="-n $1"
shift
fi
if [ "$1" = "rsync" ]; then
exec kubectl $namespace exec -i $pod -- "$@"
else # git-receive-pack '*'
exec kubectl $namespace exec -i $pod -- /bin/sh -c "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment