Created
January 26, 2022 22:00
-
-
Save joestringer/8f2179bf80ecc81952c986beef50d876 to your computer and use it in GitHub Desktop.
Deploy a new kernel into a GKE VM
This file contains 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 | |
set -eo pipefail | |
FETCH_DEBS=fetch_ubuntu_mainline_debs.sh | |
FETCH_DEBS_PATH=$PWD/$FETCH_DEBS | |
if [[ $# -lt 2 ]]; then | |
>&2 echo "usage: $0 <KERNEL-VERSION> <NODE-NAME> [NODE-NAME ...]" | |
>&2 | |
>&2 echo "Select instances from the list below:" | |
>&2 gcloud compute instances list | |
exit 1 | |
fi | |
ERSION=$(echo "$1" | sed 's/^v//') | |
shift | |
if ! echo $ERSION | grep -q "[0-9].[0-9]\+"; then | |
>&2 echo "Unrecognized kernel version '$ERSION'. Should be X.Y." | |
exit 1 | |
fi | |
echo "Deploying kernel $VERSION..." | |
for node in "$@"; do | |
gcloud compute scp $FETCH_DEBS_PATH $node:/tmp; | |
gcloud compute ssh $node -- \ | |
'cd /tmp && ./'$FETCH_DEBS' '$ERSION' \ | |
&& sudo dpkg -i *.deb \ | |
&& sudo systemctl reboot -i' \ | |
|| >&2 echo "WARNING: ssh exit-code $?" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment