Skip to content

Instantly share code, notes, and snippets.

@AlexsJones
Last active January 4, 2023 11:10
Show Gist options
  • Save AlexsJones/4c9b756d45f594450100efaf0b23d916 to your computer and use it in GitHub Desktop.
Save AlexsJones/4c9b756d45f594450100efaf0b23d916 to your computer and use it in GitHub Desktop.
Install MK8s
#!/bin/sh
set -e
set -o noglob
# Usage:
# curl ... | ENV_VAR=... sh -
# or
# ENV_VAR=... ./install.sh
#
# Environment variables:
# - MK8S_CHANNEL
# If set this will set a non-default channel
verify_ubuntu(){
if [ -z "$(uname -a | grep Ubuntu)" ]; then
echo "could not detect Ubuntu OS"
exit
fi
}
verify_snap(){
if ! [ -x "$(command -v snap)" ]
then
echo "snap could not be found"
exit
fi
}
install(){
if [ -x "$(command -v microk8s)" ]
then
if [ -n "${MK8S_CHANNEL}" ]; then
sudo snap refresh microk8s --channel="${MK8S_CHANNEL}"
else
echo "Microk8s is already installed ๐Ÿ™ˆ"
fi
else
echo "Installing Microk8s ๐Ÿš€"
if [ -n "${MK8S_CHANNEL}" ]; then
sudo snap install microk8s --classic --channel="${MK8S_CHANNEL}"
else
sudo snap install microk8s --classic
fi
fi
}
{
verify_ubuntu
verify_snap
install
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment