Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antonfisher/06461c7ac9ba147884222a2cea815fda to your computer and use it in GitHub Desktop.
Save antonfisher/06461c7ac9ba147884222a2cea815fda to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Run this script from githib:
#bash <(curl -s https://gist.githubusercontent.com/antonfisher/06461c7ac9ba147884222a2cea815fda/raw/77af2d09d7ed517f641fc888d0ff3ff12604d4e5/deploy-minikube-nexentaedge-cluster-on-ubuntu.sh)
# cleanup
#sudo apt remove virtualbox kubectl; sudo rm -rf /usr/local/bin/minikube; rm -rf ~/.minikube
# port forwarding if run inside ubuntu vm (IP - vm ip)
#sudo ssh -L 0.0.0.0:80001:IP:31080 root@IP
YAML_REPO=https://raw.githubusercontent.com/Nexenta/edge-kubernetes/master/
YAML_FILE=nedge-cluster-lfs-solo.yaml;
cd /tmp;
# --- install virtualbox ---
read -p "If this is a virtual machine answer 'n'! Install VirtualBox? [Y/n] " -r;
USE_VIRTUALBOX=0;
if [[ ! $REPLY =~ ^[Nn]$ ]]
then
USE_VIRTUALBOX=1;
VIRTUALBOX_INSTALLED=$(command -v virtualbox >/dev/null 2>&1;echo $?)
if [[ "$VIRTUALBOX_INSTALLED" -ne "0" ]]
then
echo "Installing virtualbox...";
sudo apt update;
sudo apt install -y virtualbox;
#wget https://download.virtualbox.org/virtualbox/5.2.12/virtualbox-5.2_5.2.12-122591~Ubuntu~yakkety_amd64.deb;
#sudo dpkg -i ./virtualbox-5.2_5.2.12-122591~Ubuntu~yakkety_amd64.deb;
fi
echo;
fi
# --- install docker ---
DOCKER_INSTALLED=$(command -v docker >/dev/null 2>&1;echo $?)
if [[ "$DOCKER_INSTALLED" -ne "0" ]]
then
echo "Installing docker...";
sudo apt update;
sudo apt install -y docker.io;
echo;
fi
# --- install kubectl ---
KUBECTL_INSTALLED=$(command -v kubectl >/dev/null 2>&1;echo $?)
if [[ "$KUBECTL_INSTALLED" -ne "0" ]]
then
echo "Installing kubectl..."
sudo apt update;
sudo apt install -y apt-transport-https;
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -;
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update;
sudo apt install -y kubectl;
echo;
fi
# --- install minikube ---
MINIKUBE_INSTALLED=$(command -v minikube >/dev/null 2>&1;echo $?)
if [[ "$MINIKUBE_INSTALLED" -ne "0" ]]
then
echo "Installing minikube...";
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.26.1/minikube-linux-amd64 &&\
chmod +x minikube &&\
sudo mv minikube /usr/local/bin/;
else
echo "Stopping existing minikube...";
minikube stop;
echo;
fi
echo "Deleting minikube vm...";
minikube delete;
# --- run minikube with NexentaEdge ---
echo "Starting minikube (with kubectl)...";
mkdir -p ~/.minikube/files/usr/bin &&\
cp /usr/bin/kubectl ~/.minikube/files/usr/bin/;
if [[ "$USE_VIRTUALBOX" -eq "1" ]]
then
minikube start;
else
minikube start --vm-driver=none;
fi
echo "Downloading NexentaEdge yaml file...";
touch ${YAML_FILE} &&\
rm ${YAML_FILE} &&\
wget "${YAML_REPO}${YAML_FILE}" &&\
sed -i.bak -e 's/\/mnt/\/mnt\/sda1/g' ${YAML_FILE} &&\
(diff ${YAML_FILE}.bak ${YAML_FILE} || true);
echo "Removing existing NexentaEdge deployment...";
kubectl get namespaces --show-labels;
kubectl delete -f ${YAML_FILE};
while (kubectl get pods -n nedge|grep "nedge") > /dev/null;
do
kubectl get pods -n nedge;
echo "Waiting for termination..."
sleep 5;
done
echo "Done:";
kubectl get pods -n nedge;
while (kubectl get namespaces --show-labels|grep "nedge") > /dev/null;
do
kubectl get namespaces --show-labels;
echo "Waiting for termination..."
sleep 5;
done
sleep 10;
echo "Done:";
kubectl get namespaces --show-labels;
echo;
echo "Deploying NexentaEdge...";
kubectl create -f /tmp/${YAML_FILE} &&\
echo -e "\n\nNexentaEdge browser UI: http://$(minikube ip):31080\n" &&\
(command -v notify-send >/dev/null 2>&1 && notify-send "minikube is running, wait STATUS to be Runnung (3/3)" || true) &&\
watch -n1 kubectl get pods -n nedge;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment