From 39e7fe773d606812f1f62fb4b033883094567103 Mon Sep 17 00:00:00 2001 From: Sachin Agarwal Date: Fri, 18 Dec 2020 16:51:37 -0500 Subject: [PATCH] feature/implemented-release-scripts Implementing a system for the install scripts pulling down the right version --- .../install-application-stack.sh | 45 ++++++++++++++----- .../install-microk8s-on-ubuntu.sh | 13 ++++-- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/code/local-kubernetes-cluster-installation/install-application-stack.sh b/code/local-kubernetes-cluster-installation/install-application-stack.sh index 01fa3e4..38d82fb 100644 --- a/code/local-kubernetes-cluster-installation/install-application-stack.sh +++ b/code/local-kubernetes-cluster-installation/install-application-stack.sh @@ -13,12 +13,33 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This script needs to run as the root user. +# There are two command line arguments (both optional) but quite important to understand +# $1 is the RELEASENAME you want to install from github +# $2 is the USER for whom to install this. + +# Please make sure the user matches the one for which you installed and configured Kubernetes + + +DEFAULTRELEASENAME="candair-0.3" # Change this as required with new tags (before you tag!!!) +date echo "Starting BigBitBus Kubernetes Automation Toolkit (KAT) cluster application installations" if [ ! -z $1 ] then - export INSTALLUSER=$1 + export RELEASENAME=$1 +else + export RELEASENAME=$DEFAULTRELEASENAME +fi + +echo "Installing KAT release $RELEASENAME." + +export RELEASEDIRNAME="kubernetes-automation-toolkit-"$RELEASENAME + +if [ ! -z $2 ] +then + export INSTALLUSER=$2 else export INSTALLUSER=$(ls /home/* -d | head -n 1 | cut -d/ -f3) fi @@ -27,44 +48,44 @@ export KUBECONFIG=/home/$INSTALLUSER/.kube/config kubectl config set-context microk8s cd /home/$INSTALLUSER # Pull zipped files -rm -rf bigbitbus-kat-main # Clean out any old run -rm bigbitbus-kat-main.zip -wget https://github.com/BigBitBusInc/kubernetes-automation-toolkit/archive/candair-0.2.zip -unzip bigbitbus-kat-main.zip +rm -rf $RELEASEDIRNAME # Clean out any old run +rm $RELEASENAME.zip +wget https://github.com/BigBitBusInc/kubernetes-automation-toolkit/archive/$RELEASENAME.zip +unzip $RELEASENAME.zip # Postgres -cd /home/$INSTALLUSER/bigbitbus-kat-main/code/k8s-common-code/postgres-db/ +cd /home/$INSTALLUSER/$RELEASEDIRNAME/code/k8s-common-code/postgres-db/ helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update helm upgrade --install pgdb bitnami/postgresql -f pg-values.yaml --namespace pg --create-namespace # Monitoring -cd /home/$INSTALLUSER/bigbitbus-kat-main/code/k8s-common-code/monitoring/ +cd /home/$INSTALLUSER/$RELEASEDIRNAME/code/k8s-common-code/monitoring/ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add stable https://charts.helm.sh/stable helm repo update helm upgrade --install monitoring-stack prometheus-community/kube-prometheus-stack -f ./prometheus-grafana-monitoring-stack-values.yaml --namespace monitoring --create-namespace # K8s Dashboard -cd /home/$INSTALLUSER/bigbitbus-kat-main/code/k8s-common-code/k8sdashboard/ +cd /home/$INSTALLUSER/$RELEASEDIRNAME/code/k8s-common-code/k8sdashboard/ helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ helm repo update helm upgrade --install k8sdashboard kubernetes-dashboard/kubernetes-dashboard -f ./dashboard-values.yaml --namespace dashboard --create-namespace # Backend kubectl create namespace be -cd /home/$INSTALLUSER/bigbitbus-kat-main/code/app-code/api/todo-python-django/ +cd /home/$INSTALLUSER/$RELEASEDIRNAME/code/app-code/api/todo-python-django/ skaffold run --default-repo localhost:32000 # Frontend kubectl create namespace fe -cd /home/$INSTALLUSER/bigbitbus-kat-main/code/app-code/frontend/todo-vuejs/ +cd /home/$INSTALLUSER/$RELEASEDIRNAME/code/app-code/frontend/todo-vuejs/ skaffold run --default-repo localhost:32000 -chown -R $INSTALLUSER:$INSTALLUSER /home/$INSTALLUSER/bigbitbus-kat-main/ +chown -R $INSTALLUSER:$INSTALLUSER /home/$INSTALLUSER/$RELEASEDIRNAME/ cd /home/$INSTALLUSER -rm bigbitbus-kat-main.zip +rm $RELEASENAME.zip # Print what was deployed for later debugging kubectl get all --all-namespaces echo "Ended BigBitBus Kubernetes Automation Toolkit (KAT) application installation script" diff --git a/code/local-kubernetes-cluster-installation/install-microk8s-on-ubuntu.sh b/code/local-kubernetes-cluster-installation/install-microk8s-on-ubuntu.sh index 4d0acdc..28b9b00 100644 --- a/code/local-kubernetes-cluster-installation/install-microk8s-on-ubuntu.sh +++ b/code/local-kubernetes-cluster-installation/install-microk8s-on-ubuntu.sh @@ -13,13 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This script needs to run as the root user. +# There are two command line arguments (both optional) but quite important to understand +# $1 is the KUBERNETES VERSION +# $2 is the USER for whom to install this. + +DEFAULTKUBERNETESVERSION="1.19" +date echo "Starting BigBitBus Kubernetes Automation Toolkit (KAT) Microk8s installation script" if [ ! -z $1 ] then export KUBEVERSION=$1 else - export KUBEVERSION="1.19" + export KUBEVERSION=$DEFAULTKUBERNETESVERSION fi echo "Installing Kubernetes version " $KUBEVERSION @@ -43,9 +50,9 @@ apt-get install unzip # Note - we pegged the Kubernetes version here snap install microk8s --classic --channel=1.19 -snap install docker --channel=19.03 +snap install --stable docker snap install kubectl --classic --channel=1.19 -snap install helm --classic --channel=3.4.2 +snap install helm --classic --channel=3.4 sleep 60 # Sometimes microk8s needs time to stabilize cd /tmp curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \