Last active
February 16, 2024 09:02
-
-
Save arrase/1ba73ae80f08fc7eab2918652767a2dd to your computer and use it in GitHub Desktop.
Upload busybox binaries to kubernetes pods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
help(){ | |
echo | |
echo "Usage:" | |
echo "add-bin.sh <bin_name> <pod> <dest_path>" | |
echo | |
echo "Example:" | |
echo "add-bin.sh vi my-pod-5df5467c97-fqbzw /mnt/disk" | |
echo | |
} | |
while getopts ":h" option; do | |
case $option in | |
h) # display Help | |
help | |
exit;; | |
esac | |
done | |
if [ $# -lt 3 ]; then | |
help | |
exit 2 | |
fi | |
BASE_URL="https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/" | |
UPNAME=$(echo $1 | tr '[:lower:]' '[:upper:]') | |
curl $BASE_URL/busybox_$UPNAME -o $1 | |
chmod a+x $1 | |
kubectl cp $1 $2:$3 | |
rm $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment