Last active
January 4, 2023 11:10
-
-
Save AlexsJones/4c9b756d45f594450100efaf0b23d916 to your computer and use it in GitHub Desktop.
Install MK8s
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/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