Skip to content

Instantly share code, notes, and snippets.

@ReallyLiri
Created July 11, 2019 08:57
Show Gist options
  • Save ReallyLiri/df97b67b6dc35185ab72f5a7834afb31 to your computer and use it in GitHub Desktop.
Save ReallyLiri/df97b67b6dc35185ab72f5a7834afb31 to your computer and use it in GitHub Desktop.
KubernetesRsync
#!/bin/bash
# USAGE: ./krsync.sh <src> <dst> , with either src/dst dir pointing to a pod (of the format 'pod:/<path>')
# Check if we are running within --rsh already (remote shell)
if [ -z "$KRSYNC_STARTED" ]; then
# not using --rsh
export KRSYNC_STARTED=true
exec rsync --blocking-io --rsh "$0" -a --progress --stats $@ # re-activate the script as remote shell
fi
# Running as --rsh !
pod=$1
shift
exec kubectl exec -i $pod -- "$@"
unset KRSYNC_STARTED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment