From d9dfc8d4695c504569cec21c036dd8b0a719508e Mon Sep 17 00:00:00 2001 From: rovandep Date: Thu, 13 May 2021 12:15:00 +0200 Subject: [PATCH 01/14] change default namespace from kube-system to storageos-operator --- sh/deploy-storageos-cluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index be9dd5fc4..90fff0a94 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -21,7 +21,7 @@ export OPERATOR_VERSION='v2.4.0-rc.1' export CLI_VERSION='v2.4.0-rc.1' export STOS_VERSION='v2.4.0-rc.1' export STORAGEOS_OPERATOR_LABEL='name=storageos-cluster-operator' -export STOS_NAMESPACE='kube-system' +export STOS_NAMESPACE='storageos-operator' export ETCD_NAMESPACE='storageos-etcd' export STOS_CLUSTERNAME='self-evaluation' From 637b89db8c54381df378bf47b9f96f4eaec45e72 Mon Sep 17 00:00:00 2001 From: rovandep Date: Thu, 13 May 2021 16:31:25 +0200 Subject: [PATCH 02/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 105 +++++++++++++++++++++++++++++---- 1 file changed, 92 insertions(+), 13 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 90fff0a94..2f07a8627 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -1,5 +1,13 @@ #!/bin/bash +############################################################################# +# Script Name : deploy-storageos-cluster.sh +# Description : Install StorageOS Self-Evaluation Cluster +# Args : +# Author : StorageOS +# Issues : Issues&PR https://github.com/storageos/storageos.github.io +############################################################################# + set -euo pipefail # StorageOS Self-Evaluation This script will install StorageOS onto a @@ -17,19 +25,96 @@ set -euo pipefail # The following variables may be tuned as desired. The defaults should work in # most environments. -export OPERATOR_VERSION='v2.4.0-rc.1' -export CLI_VERSION='v2.4.0-rc.1' -export STOS_VERSION='v2.4.0-rc.1' -export STORAGEOS_OPERATOR_LABEL='name=storageos-cluster-operator' -export STOS_NAMESPACE='storageos-operator' -export ETCD_NAMESPACE='storageos-etcd' -export STOS_CLUSTERNAME='self-evaluation' + +# Getting the latest and greatest to deploy as a self-evaluation. +if ! command -v curl &> /dev/null +then + OPERATOR_VERSION='v2.3.4' +else + OPERATOR_VERSION=`curl --silent "https://api.github.com/repos/storageos/cluster-operator/releases/latest" |awk -F '"' '/tag_name/{print $4}'` +fi +STORAGEOS_OPERATOR_LABEL='name=storageos-cluster-operator' +STOS_NAMESPACE='kube-system' +ETCD_NAMESPACE='storageos-etcd' +STOS_CLUSTERNAME='self-evaluation' +while getopts c:n:e:v:l: option +do + case "${option}" in + c) STOS_CLUSTERNAME=${OPTARG};; + n) STOS_NAMESPACE=${OPTARG};; + e) ETCD_NAMESPACE=${OPTARG};; + v) OPERATOR_VERSION=${OPTARG};; + l) + esac +done +CLI_VERSION=${OPERATOR_VERSION} +STOS_VERSION=${OPERATOR_VERSION} + # Define some colours for later RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color +echo -e "${RED}Welcome to the ${NC}STORAGE${GREEN}OS${RED} self-evaluation installation script.${NC}" +echo -e "${GREEN}Self-Evaluation guide: https://docs.storageos.com/docs/self-eval${NC}" +echo + +# Checking and exiting if requirements are not met. +echo -e "${GREEN}Checking requirements:${NC}" + +echo -e " Checking Kubectl..." +if ! command -v kubectl &> /dev/null +then + echo -e "${RED} Kubectl could not be found on this shell.${NC}" + echo -e "${RED} Kubectl is used to access Kubernetes clusters and is required.${NC}" + echo -e "${RED} Please intall kubectl: https://kubernetes.io/docs/tasks/tools/${NC}" + exit +fi +echo -e "${GREEN} Kubectl found!${NC}" + +echo -e " Checking node count (minimum 3)..." +NODECOUNT=`kubectl get nodes -o name |tee /dev/stderr| wc -l` +if [ $NODECOUNT -lt 3 ] +then + echo -e "${RED} Current node count is $NODECOUNT.${NC}" + echo -e "${RED} Required minimum node is 3.${NC}" + exit +fi +echo -e "${GREEN} Current node count is $NODECOUNT!.${NC}" + +echo +echo -e "${GREEN}The script will deploy a StorageOS cluster: ${NC}" +echo -e "${GREEN} StorageOS cluster named ${RED}${STOS_CLUSTERNAME}${GREEN}.${NC}" +echo -e "${GREEN} StorageOS version ${RED}${STOS_VERSION}${GREEN} into namespace ${RED}${STOS_NAMESPACE}${GREEN}.${NC}" +echo -e "${GREEN} ETCD into namespace ${RED}${ETCD_NAMESPACE}${GREEN}.${NC}" +echo -e "${GREEN}The installation process will stop on any encountered error.${NC}" +echo + +# Having the courtesy to check if happy with the basics settings +read -p "Proceed with these settings? (y/n) " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]] +then + echo + echo -e "Usage: $0 [OPTION]..." + echo -e "${RED}Install a ${NC}STORAGE${GREEN}OS${RED} Self-Evaluation cluster on Kubernetes.${NC}" + echo + echo -e " -c ${NC}STORAGE${GREEN}OS${NC} cluser name." + echo -e " -n Kubernetes namespace to install ${NC}STORAGE${GREEN}OS${NC} in." + echo -e " -e Kubernetes namespace to install ETCD in." + echo -e " -v ${NC}STORAGE${GREEN}OS${NC} version to deploy." + echo -e " Check https://github.com/storageos/cluster-operator/releases" + echo + echo "Example: $0 -e my-etcd -n my-storageos -c demo-cluster -v v2.3.4" + echo "Issues: " + echo + exit +fi +echo "good" + + +exit # If running in Openshift, an SCC is needed to start Pods if grep -q "openshift" <(kubectl get node --show-labels); then @@ -38,12 +123,6 @@ if grep -q "openshift" <(kubectl get node --show-labels); then sleep 5 fi -echo -e "${GREEN}Welcome to the StorageOS quick installation script.${NC}" -echo -e "${GREEN}I will install StorageOS version ${STOS_VERSION} into${NC}" -echo -e "${GREEN}namespace ${STOS_NAMESPACE} now. If I encounter any errors${NC}" -echo -e "${GREEN}I will stop immediately.${NC}" -echo - # First, we create an etcd cluster. Our example uses the CoreOS operator to # create a 3 pod cluster using transient storage. This is *unsuitable for # production deployments* but fine for evaluation purposes. The data in the From 66e292801ca44e690599438089decc7ea8ffa489 Mon Sep 17 00:00:00 2001 From: rovandep Date: Thu, 13 May 2021 16:34:35 +0200 Subject: [PATCH 03/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 2f07a8627..1e9a42273 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -93,6 +93,7 @@ echo # Having the courtesy to check if happy with the basics settings read -p "Proceed with these settings? (y/n) " -n 1 -r + echo if [[ ! $REPLY =~ ^[Yy]$ ]] then From 02d7ff18c9436b832e4779448e02c8ed991c04f8 Mon Sep 17 00:00:00 2001 From: rovandep Date: Thu, 13 May 2021 17:36:20 +0200 Subject: [PATCH 04/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 581 +++++++++++++++++---------------- 1 file changed, 292 insertions(+), 289 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 1e9a42273..b6d6da0fc 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -92,13 +92,13 @@ echo -e "${GREEN}The installation process will stop on any encountered error.${N echo # Having the courtesy to check if happy with the basics settings -read -p "Proceed with these settings? (y/n) " -n 1 -r +read < /dev/tty -n1 -r -p "Proceed with these settings? (y/n) " echo if [[ ! $REPLY =~ ^[Yy]$ ]] then echo - echo -e "Usage: $0 [OPTION]..." + echo -e "Usage: ./deploy-storageos-cluster.sh [OPTION]..." echo -e "${RED}Install a ${NC}STORAGE${GREEN}OS${RED} Self-Evaluation cluster on Kubernetes.${NC}" echo echo -e " -c ${NC}STORAGE${GREEN}OS${NC} cluser name." @@ -107,300 +107,303 @@ then echo -e " -v ${NC}STORAGE${GREEN}OS${NC} version to deploy." echo -e " Check https://github.com/storageos/cluster-operator/releases" echo - echo "Example: $0 -e my-etcd -n my-storageos -c demo-cluster -v v2.3.4" + echo "Eg: ./deploy-storageos-cluster.sh -e my-etcd -n my-storageos -c demo-cluster -v v2.3.4" + echo " curl -fsSL https://storageos.run | bash -s -- -e my-etcd -n my-storageos -c demo-cluster -v ${STOS_VERSION}" + echo echo "Issues: " echo exit fi -echo "good" - - -exit -# If running in Openshift, an SCC is needed to start Pods -if grep -q "openshift" <(kubectl get node --show-labels); then - oc adm policy add-scc-to-user anyuid \ - system:serviceaccount:${ETCD_NAMESPACE}:default - sleep 5 -fi -# First, we create an etcd cluster. Our example uses the CoreOS operator to -# create a 3 pod cluster using transient storage. This is *unsuitable for -# production deployments* but fine for evaluation purposes. The data in the -# etcd will not persist outside of a reboot. -echo -e "${GREEN}Creating etcd namespace ${ETCD_NAMESPACE}${NC}" -kubectl create namespace ${ETCD_NAMESPACE} - -echo -e "${GREEN}Creating etcd ClusterRole and ClusterRoleBinding${NC}" -kubectl -n ${ETCD_NAMESPACE} create -f-<' | base64 - apiUsername: c3RvcmFnZW9z - apiPassword: c3RvcmFnZW9z - # CSI Credentials - csiProvisionUsername: c3RvcmFnZW9z - csiProvisionPassword: c3RvcmFnZW9z - csiControllerPublishUsername: c3RvcmFnZW9z - csiControllerPublishPassword: c3RvcmFnZW9z - csiNodePublishUsername: c3RvcmFnZW9z - csiNodePublishPassword: c3RvcmFnZW9z - csiControllerExpandUsername: c3RvcmFnZW9z - csiControllerExpandPassword: c3RvcmFnZW9z -END - -# Now that we have the operator installed, and a secret defined, it is time to -# install StorageOS itself. We default to the kube-system namespace, which -# gives us some protection against eviction by the Kubelet under conditions of -# contention. -# In the StorageOS CR we declare the DNS name for the etcd deployment and -# service we created earlier. -echo -e "${GREEN}Installing StorageOS Cluster version ${STOS_VERSION}${NC}" -kubectl create -f - <' | base64 +# apiUsername: c3RvcmFnZW9z +# apiPassword: c3RvcmFnZW9z +# # CSI Credentials +# csiProvisionUsername: c3RvcmFnZW9z +# csiProvisionPassword: c3RvcmFnZW9z +# csiControllerPublishUsername: c3RvcmFnZW9z +# csiControllerPublishPassword: c3RvcmFnZW9z +# csiNodePublishUsername: c3RvcmFnZW9z +# csiNodePublishPassword: c3RvcmFnZW9z +# csiControllerExpandUsername: c3RvcmFnZW9z +# csiControllerExpandPassword: c3RvcmFnZW9z +# END + +# # Now that we have the operator installed, and a secret defined, it is time to +# # install StorageOS itself. We default to the kube-system namespace, which +# # gives us some protection against eviction by the Kubelet under conditions of +# # contention. +# # In the StorageOS CR we declare the DNS name for the etcd deployment and +# # service we created earlier. +# echo -e "${GREEN}Installing StorageOS Cluster version ${STOS_VERSION}${NC}" +# kubectl create -f - < Date: Thu, 13 May 2021 19:18:40 +0200 Subject: [PATCH 05/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index b6d6da0fc..66df2a1b1 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -29,7 +29,7 @@ set -euo pipefail # Getting the latest and greatest to deploy as a self-evaluation. if ! command -v curl &> /dev/null then - OPERATOR_VERSION='v2.3.4' + OPERATOR_VERSION='v2.4.0-rc.1' else OPERATOR_VERSION=`curl --silent "https://api.github.com/repos/storageos/cluster-operator/releases/latest" |awk -F '"' '/tag_name/{print $4}'` fi @@ -58,6 +58,7 @@ NC='\033[0m' # No Color echo -e "${RED}Welcome to the ${NC}STORAGE${GREEN}OS${RED} self-evaluation installation script.${NC}" echo -e "${GREEN}Self-Evaluation guide: https://docs.storageos.com/docs/self-eval${NC}" +echo -e " ${RED}This deployment is suitable for testing purposes only.${NC}" echo # Checking and exiting if requirements are not met. @@ -85,8 +86,8 @@ echo -e "${GREEN} Current node count is $NODECOUNT!.${NC}" echo echo -e "${GREEN}The script will deploy a StorageOS cluster: ${NC}" -echo -e "${GREEN} StorageOS cluster named ${RED}${STOS_CLUSTERNAME}${GREEN}.${NC}" -echo -e "${GREEN} StorageOS version ${RED}${STOS_VERSION}${GREEN} into namespace ${RED}${STOS_NAMESPACE}${GREEN}.${NC}" +echo -e "${GREEN} ${NC}STORAGE${GREEN}OS${NC} cluster named ${RED}${STOS_CLUSTERNAME}${GREEN}.${NC}" +echo -e "${GREEN} ${NC}STORAGE${GREEN}OS${NC} version ${RED}${STOS_VERSION}${GREEN} into namespace ${RED}${STOS_NAMESPACE}${GREEN}.${NC}" echo -e "${GREEN} ETCD into namespace ${RED}${ETCD_NAMESPACE}${GREEN}.${NC}" echo -e "${GREEN}The installation process will stop on any encountered error.${NC}" echo @@ -107,7 +108,7 @@ then echo -e " -v ${NC}STORAGE${GREEN}OS${NC} version to deploy." echo -e " Check https://github.com/storageos/cluster-operator/releases" echo - echo "Eg: ./deploy-storageos-cluster.sh -e my-etcd -n my-storageos -c demo-cluster -v v2.3.4" + echo "Eg: ./deploy-storageos-cluster.sh -e my-etcd -n my-storageos -c demo-cluster -v ${STOS_VERSION}" echo " curl -fsSL https://storageos.run | bash -s -- -e my-etcd -n my-storageos -c demo-cluster -v ${STOS_VERSION}" echo echo "Issues: " @@ -115,17 +116,13 @@ then exit fi - - - -exit - -# # If running in Openshift, an SCC is needed to start Pods -# if grep -q "openshift" <(kubectl get node --show-labels); then -# oc adm policy add-scc-to-user anyuid \ -# system:serviceaccount:${ETCD_NAMESPACE}:default -# sleep 5 -# fi +# If running in Openshift, an SCC is needed to start Pods +if grep -q "openshift" <(kubectl get node --show-labels); then + echo -e "${GREEN}OpenShift detected - adding SCC for ${RED}${ETCD_NAMESPACE}${GREEN}${NC}." + oc adm policy add-scc-to-user anyuid \ + system:serviceaccount:${ETCD_NAMESPACE}:default + sleep 5 +fi # # First, we create an etcd cluster. Our example uses the CoreOS operator to # # create a 3 pod cluster using transient storage. This is *unsuitable for From ff3af4df4bff722f56369898b45192a57a5d35b0 Mon Sep 17 00:00:00 2001 From: rovandep Date: Thu, 13 May 2021 22:46:20 +0200 Subject: [PATCH 06/14] refactoring deploy-stroage-cluster.sh --- sh/deploy-storageos-cluster.sh | 415 ++++++++++++++++++--------------- 1 file changed, 222 insertions(+), 193 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 66df2a1b1..ab8b9f10b 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -64,28 +64,28 @@ echo # Checking and exiting if requirements are not met. echo -e "${GREEN}Checking requirements:${NC}" -echo -e " Checking Kubectl..." +echo -ne " Checking Kubectl......................................" if ! command -v kubectl &> /dev/null -then +then + echo -ne "${RED}NOK${NC}\n" echo -e "${RED} Kubectl could not be found on this shell.${NC}" echo -e "${RED} Kubectl is used to access Kubernetes clusters and is required.${NC}" echo -e "${RED} Please intall kubectl: https://kubernetes.io/docs/tasks/tools/${NC}" exit fi -echo -e "${GREEN} Kubectl found!${NC}" +echo -ne ".${GREEN}OK${NC}\n" -echo -e " Checking node count (minimum 3)..." -NODECOUNT=`kubectl get nodes -o name |tee /dev/stderr| wc -l` +echo -ne " Checking node count (minimum 3)......................." +NODECOUNT=`kubectl get nodes -o name | wc -l` if [ $NODECOUNT -lt 3 ] then - echo -e "${RED} Current node count is $NODECOUNT.${NC}" - echo -e "${RED} Required minimum node is 3.${NC}" + echo -e "${RED}NOK${NC}\n" exit fi -echo -e "${GREEN} Current node count is $NODECOUNT!.${NC}" +echo -ne ".${GREEN}OK${NC}\n" echo -echo -e "${GREEN}The script will deploy a StorageOS cluster: ${NC}" +echo -e "${GREEN}The script will deploy a ${NC}STORAGE${GREEN}OS cluster: ${NC}" echo -e "${GREEN} ${NC}STORAGE${GREEN}OS${NC} cluster named ${RED}${STOS_CLUSTERNAME}${GREEN}.${NC}" echo -e "${GREEN} ${NC}STORAGE${GREEN}OS${NC} version ${RED}${STOS_VERSION}${GREEN} into namespace ${RED}${STOS_NAMESPACE}${GREEN}.${NC}" echo -e "${GREEN} ETCD into namespace ${RED}${ETCD_NAMESPACE}${GREEN}.${NC}" @@ -116,197 +116,226 @@ then exit fi +# Starting deployment +echo -e "${GREEN}Starting ${NC}STORAGE${GREEN}OS deployment:${NC}" +echo -ne " Is it OpenShift?......................................" + # If running in Openshift, an SCC is needed to start Pods -if grep -q "openshift" <(kubectl get node --show-labels); then - echo -e "${GREEN}OpenShift detected - adding SCC for ${RED}${ETCD_NAMESPACE}${GREEN}${NC}." +if grep -q "openshift" <(kubectl get node --show-labels); +then + echo -ne "${GREEN}YES${NC}\n" + echo -ne " OpenShift - adding SCC for ${RED}${ETCD_NAMESPACE}${GREEN}${NC} ............" oc adm policy add-scc-to-user anyuid \ system:serviceaccount:${ETCD_NAMESPACE}:default sleep 5 + echo -ne "${GREEN}OK${NC}\n" fi - -# # First, we create an etcd cluster. Our example uses the CoreOS operator to -# # create a 3 pod cluster using transient storage. This is *unsuitable for -# # production deployments* but fine for evaluation purposes. The data in the -# # etcd will not persist outside of a reboot. -# echo -e "${GREEN}Creating etcd namespace ${ETCD_NAMESPACE}${NC}" -# kubectl create namespace ${ETCD_NAMESPACE} - -# echo -e "${GREEN}Creating etcd ClusterRole and ClusterRoleBinding${NC}" -# kubectl -n ${ETCD_NAMESPACE} create -f-< /dev/null +echo -ne "${GREEN}OK${NC}\n" + +echo -ne " Creating etcd ClusterRoleBinding......................" +kubectl -n ${ETCD_NAMESPACE} create -f- 1>/dev/null</dev/null</dev/null</dev/null</dev/null + +echo -ne ".${GREEN}OK${NC}\n" + + +# Wait for the operator to become ready +echo -ne " Waiting on STORAGE${GREEN}OS${NC} operator to be running..........." +phase="$(kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase)" +while ! grep -q "Running" <(echo "${phase}"); do + sleep 2 + phase="$(kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase)" +done +echo -ne ".${GREEN}OK${NC}\n" -# # Wait for etcd operator to become ready -# phase="$(kubectl -n ${ETCD_NAMESPACE} get pod -lname=etcd-operator --no-headers -ocustom-columns=status:.status.phase)" -# while ! grep -q "Running" <(echo "${phase}"); do -# sleep 2 -# phase="$(kubectl -n ${ETCD_NAMESPACE} get pod -lname=etcd-operator --no-headers -ocustom-columns=status:.status.phase)" -# done - -# # Create etcd CustomResource -# # This will install 3 etcd pods into the cluster using ephemeral storage. It -# # will also create a service endpoint, by which we can refer to the cluster in -# # the installation for StorageOS itself below. -# echo -e "${GREEN}Creating etcd cluster in namespace ${ETCD_NAMESPACE}${NC}" -# kubectl -n ${ETCD_NAMESPACE} create -f- < Date: Thu, 13 May 2021 22:47:03 +0200 Subject: [PATCH 07/14] refactoring deploy-storageos-cluster.sh --- sh/delete-storageos-cluster.sh | 337 +++++++++++++++++++++++++++++++++ 1 file changed, 337 insertions(+) create mode 100755 sh/delete-storageos-cluster.sh diff --git a/sh/delete-storageos-cluster.sh b/sh/delete-storageos-cluster.sh new file mode 100755 index 000000000..a00f01b2c --- /dev/null +++ b/sh/delete-storageos-cluster.sh @@ -0,0 +1,337 @@ +#!/bin/bash + +############################################################################# +# Script Name : delete-storageos-cluster.sh +# Description : Uninstall StorageOS Self-Evaluation Cluster +# Args : +# Author : StorageOS +# Issues : Issues&PR https://github.com/storageos/storageos.github.io +############################################################################# + +set -euo pipefail + +# StorageOS Self-Evaluation This script will remove StorageOS from a +# Kubernetes cluster +# +# This script removes a self-evaluation cluster based on the installation +# instructions in our self-evaluation guide: https://docs.storageos.com/docs/self-eval. +# +# This script will removes all components and persistent volumes from the +# Kubernetes cluster. Please see the "Uninstall StorageOS" documentation for +# more information: https://docs.storageos.com/v2.4-rc/docs/operations/uninstall/ +# +# Expectations: +# - Kubernetes cluster with a minium of 3 +# nodes +# - kubectl in the PATH - kubectl access to this cluster with +# cluster-admin privileges - export KUBECONFIG as appropriate + +# The following variables may be tuned as desired. The defaults should work in +# most environments. +export OPERATOR_VERSION='v2.4.0-rc.1' +export CLI_VERSION='v2.4.0-rc.1' +export STOS_VERSION='v2.4.0-rc.1' +export STORAGEOS_OPERATOR_LABEL='name=storageos-cluster-operator' +export STOS_NAMESPACE='storageos-operator' +export ETCD_NAMESPACE='storageos-etcd' +export STOS_CLUSTERNAME='self-evaluation' + +# Define some colours for later +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + + +# If running in Openshift, an SCC is needed to start Pods +if grep -q "openshift" <(kubectl get node --show-labels); then + oc adm policy add-scc-to-user anyuid \ + system:serviceaccount:${ETCD_NAMESPACE}:default + sleep 5 +fi + +echo -e "${GREEN}Welcome to the StorageOS quick installation script.${NC}" +echo -e "${GREEN}I will install StorageOS version ${STOS_VERSION} into${NC}" +echo -e "${GREEN}namespace ${STOS_NAMESPACE} now. If I encounter any errors${NC}" +echo -e "${GREEN}I will stop immediately.${NC}" +echo + +# First, we create an etcd cluster. Our example uses the CoreOS operator to +# create a 3 pod cluster using transient storage. This is *unsuitable for +# production deployments* but fine for evaluation purposes. The data in the +# etcd will not persist outside of a reboot. +echo -e "${GREEN}Creating etcd namespace ${ETCD_NAMESPACE}${NC}" +kubectl create namespace ${ETCD_NAMESPACE} + +echo -e "${GREEN}Creating etcd ClusterRole and ClusterRoleBinding${NC}" +kubectl -n ${ETCD_NAMESPACE} create -f-<' | base64 + apiUsername: c3RvcmFnZW9z + apiPassword: c3RvcmFnZW9z + # CSI Credentials + csiProvisionUsername: c3RvcmFnZW9z + csiProvisionPassword: c3RvcmFnZW9z + csiControllerPublishUsername: c3RvcmFnZW9z + csiControllerPublishPassword: c3RvcmFnZW9z + csiNodePublishUsername: c3RvcmFnZW9z + csiNodePublishPassword: c3RvcmFnZW9z + csiControllerExpandUsername: c3RvcmFnZW9z + csiControllerExpandPassword: c3RvcmFnZW9z +END + +# Now that we have the operator installed, and a secret defined, it is time to +# install StorageOS itself. We default to the kube-system namespace, which +# gives us some protection against eviction by the Kubelet under conditions of +# contention. +# In the StorageOS CR we declare the DNS name for the etcd deployment and +# service we created earlier. +echo -e "${GREEN}Installing StorageOS Cluster version ${STOS_VERSION}${NC}" +kubectl create -f - < Date: Thu, 13 May 2021 23:08:06 +0200 Subject: [PATCH 08/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 120 +++++++++++++++++---------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index ab8b9f10b..88626cc0d 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -337,64 +337,70 @@ done echo -ne ".${GREEN}OK${NC}\n" -# # The StorageOS secret contains credentials for our API, as well as CSI -# echo -e "${GREEN}Creating Secret definining the API Username and Password${NC}" -# kubectl create -f - <' | base64 -# apiUsername: c3RvcmFnZW9z -# apiPassword: c3RvcmFnZW9z -# # CSI Credentials -# csiProvisionUsername: c3RvcmFnZW9z -# csiProvisionPassword: c3RvcmFnZW9z -# csiControllerPublishUsername: c3RvcmFnZW9z -# csiControllerPublishPassword: c3RvcmFnZW9z -# csiNodePublishUsername: c3RvcmFnZW9z -# csiNodePublishPassword: c3RvcmFnZW9z -# csiControllerExpandUsername: c3RvcmFnZW9z -# csiControllerExpandPassword: c3RvcmFnZW9z -# END - -# # Now that we have the operator installed, and a secret defined, it is time to -# # install StorageOS itself. We default to the kube-system namespace, which -# # gives us some protection against eviction by the Kubelet under conditions of -# # contention. -# # In the StorageOS CR we declare the DNS name for the etcd deployment and -# # service we created earlier. -# echo -e "${GREEN}Installing StorageOS Cluster version ${STOS_VERSION}${NC}" -# kubectl create -f - </dev/null<' | base64 + apiUsername: c3RvcmFnZW9z + apiPassword: c3RvcmFnZW9z + # CSI Credentials + csiProvisionUsername: c3RvcmFnZW9z + csiProvisionPassword: c3RvcmFnZW9z + csiControllerPublishUsername: c3RvcmFnZW9z + csiControllerPublishPassword: c3RvcmFnZW9z + csiNodePublishUsername: c3RvcmFnZW9z + csiNodePublishPassword: c3RvcmFnZW9z + csiControllerExpandUsername: c3RvcmFnZW9z + csiControllerExpandPassword: c3RvcmFnZW9z +END + +echo -ne ".${GREEN}OK${NC}\n" + + +# Now that we have the operator installed, and a secret defined, it is time to +# install StorageOS itself. We default to the kube-system namespace, which +# gives us some protection against eviction by the Kubelet under conditions of +# contention. +# In the StorageOS CR we declare the DNS name for the etcd deployment and +# service we created earlier. +echo -ne " Creating STORAGE${GREEN}OS${NC} cluster version ${RED}${STOS_VERSION}${NC}........" +kubectl create -f- 1>/dev/null< Date: Fri, 14 May 2021 00:10:34 +0200 Subject: [PATCH 09/14] refactoring deploy-storageos-cluster.sh --- sh/delete-storageos-cluster.sh | 337 --------------------------------- sh/deploy-storageos-cluster.sh | 84 ++++---- 2 files changed, 43 insertions(+), 378 deletions(-) delete mode 100755 sh/delete-storageos-cluster.sh diff --git a/sh/delete-storageos-cluster.sh b/sh/delete-storageos-cluster.sh deleted file mode 100755 index a00f01b2c..000000000 --- a/sh/delete-storageos-cluster.sh +++ /dev/null @@ -1,337 +0,0 @@ -#!/bin/bash - -############################################################################# -# Script Name : delete-storageos-cluster.sh -# Description : Uninstall StorageOS Self-Evaluation Cluster -# Args : -# Author : StorageOS -# Issues : Issues&PR https://github.com/storageos/storageos.github.io -############################################################################# - -set -euo pipefail - -# StorageOS Self-Evaluation This script will remove StorageOS from a -# Kubernetes cluster -# -# This script removes a self-evaluation cluster based on the installation -# instructions in our self-evaluation guide: https://docs.storageos.com/docs/self-eval. -# -# This script will removes all components and persistent volumes from the -# Kubernetes cluster. Please see the "Uninstall StorageOS" documentation for -# more information: https://docs.storageos.com/v2.4-rc/docs/operations/uninstall/ -# -# Expectations: -# - Kubernetes cluster with a minium of 3 -# nodes -# - kubectl in the PATH - kubectl access to this cluster with -# cluster-admin privileges - export KUBECONFIG as appropriate - -# The following variables may be tuned as desired. The defaults should work in -# most environments. -export OPERATOR_VERSION='v2.4.0-rc.1' -export CLI_VERSION='v2.4.0-rc.1' -export STOS_VERSION='v2.4.0-rc.1' -export STORAGEOS_OPERATOR_LABEL='name=storageos-cluster-operator' -export STOS_NAMESPACE='storageos-operator' -export ETCD_NAMESPACE='storageos-etcd' -export STOS_CLUSTERNAME='self-evaluation' - -# Define some colours for later -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' # No Color - - -# If running in Openshift, an SCC is needed to start Pods -if grep -q "openshift" <(kubectl get node --show-labels); then - oc adm policy add-scc-to-user anyuid \ - system:serviceaccount:${ETCD_NAMESPACE}:default - sleep 5 -fi - -echo -e "${GREEN}Welcome to the StorageOS quick installation script.${NC}" -echo -e "${GREEN}I will install StorageOS version ${STOS_VERSION} into${NC}" -echo -e "${GREEN}namespace ${STOS_NAMESPACE} now. If I encounter any errors${NC}" -echo -e "${GREEN}I will stop immediately.${NC}" -echo - -# First, we create an etcd cluster. Our example uses the CoreOS operator to -# create a 3 pod cluster using transient storage. This is *unsuitable for -# production deployments* but fine for evaluation purposes. The data in the -# etcd will not persist outside of a reboot. -echo -e "${GREEN}Creating etcd namespace ${ETCD_NAMESPACE}${NC}" -kubectl create namespace ${ETCD_NAMESPACE} - -echo -e "${GREEN}Creating etcd ClusterRole and ClusterRoleBinding${NC}" -kubectl -n ${ETCD_NAMESPACE} create -f-<' | base64 - apiUsername: c3RvcmFnZW9z - apiPassword: c3RvcmFnZW9z - # CSI Credentials - csiProvisionUsername: c3RvcmFnZW9z - csiProvisionPassword: c3RvcmFnZW9z - csiControllerPublishUsername: c3RvcmFnZW9z - csiControllerPublishPassword: c3RvcmFnZW9z - csiNodePublishUsername: c3RvcmFnZW9z - csiNodePublishPassword: c3RvcmFnZW9z - csiControllerExpandUsername: c3RvcmFnZW9z - csiControllerExpandPassword: c3RvcmFnZW9z -END - -# Now that we have the operator installed, and a secret defined, it is time to -# install StorageOS itself. We default to the kube-system namespace, which -# gives us some protection against eviction by the Kubelet under conditions of -# contention. -# In the StorageOS CR we declare the DNS name for the etcd deployment and -# service we created earlier. -echo -e "${GREEN}Installing StorageOS Cluster version ${STOS_VERSION}${NC}" -kubectl create -f - </dev/null + +echo -ne ".${GREEN}OK${NC}\n" + + +# Check if StorageOS cli is running +echo -ne " Waiting on STORAGE${GREEN}OS${NC} CLI pod to be running............" +phase="$(kubectl --namespace=${STOS_NAMESPACE} describe pod cli)" +while ! grep -q "Running" <(echo "${phase}"); do + sleep 10 + phase="$(kubectl --namespace=${STOS_NAMESPACE} describe pod cli)" +done +echo -ne ".${GREEN}OK${NC}\n" + +echo +echo -e "${GREEN}Your ${NC}STORAGE${GREEN}OS${NC} Cluster ${GREEN}now is up and running!" +echo +echo -e "${GREEN}Now would be a good time to deploy your first volume - see${NC}" +echo -e "${GREEN}https://docs.storageos.com/docs/self-eval/#a-namestorageosvolumeaprovision-a-storageos-volume${NC}" +echo -e "${GREEN}for an example of how to mount a StorageOS volume in a pod${NC}" +echo +echo -e "${GREEN}Don't forget to license your cluster - see https://docs.storageos.com/docs/operations/licensing/${NC}" +echo +echo -e "${GREEN}This cluster has been set up with an etcd based on ephemeral${NC}" +echo -e "${GREEN}storage. It is suitable for evaluation purposes only - for${NC}" +echo -e "${GREEN}production usage please see our etcd installation nodes at${NC}" +echo -e "${GREEN}https://docs.storageos.com/docs/prerequisites/etcd/${NC}" From eca8223b3317bd71ba87e78e1a3a03126c50a76f Mon Sep 17 00:00:00 2001 From: rovandep Date: Fri, 14 May 2021 00:35:59 +0200 Subject: [PATCH 10/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 209bf0ad1..0ece12b72 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -1,11 +1,10 @@ #!/bin/bash - ############################################################################# -# Script Name : deploy-storageos-cluster.sh -# Description : Install StorageOS Self-Evaluation Cluster -# Args : +# Script Name : deploy-storageos-cluster.sh +# Description : Install StorageOS Self-Evaluation Cluster +# Args : # Author : StorageOS -# Issues : Issues&PR https://github.com/storageos/storageos.github.io +# Issues : Issues&PR https://github.com/storageos/storageos.github.io ############################################################################# set -euo pipefail From cff5f5f6723dc50be2012adf5d236442127b03fc Mon Sep 17 00:00:00 2001 From: rovandep Date: Fri, 14 May 2021 01:32:11 +0200 Subject: [PATCH 11/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 0ece12b72..478850c29 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -55,6 +55,7 @@ RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color +echo echo -e "${RED}Welcome to the ${NC}STORAGE${GREEN}OS${RED} self-evaluation installation script.${NC}" echo -e "${GREEN}Self-Evaluation guide: https://docs.storageos.com/docs/self-eval${NC}" echo -e " ${RED}This deployment is suitable for testing purposes only.${NC}" @@ -63,6 +64,18 @@ echo # Checking and exiting if requirements are not met. echo -e "${GREEN}Checking requirements:${NC}" +echo -ne " Checking for exiting STORAGE${GREEN}OS${NC} cluster................" +if kubectl get storageoscluster --all-namespaces -o name &>/dev/null; +then + echo -ne "${RED}YES${NC}\n" + echo -e " ${RED}A ${NC}STORAGE${GREEN}OS ${NC}cluster${RED} is already installed on this Kubernetes cluster." + echo + exit + # todo: include a clean-up option from this breaking point +else + echo -ne ".${GREEN}NO${NC}\n" +fi + echo -ne " Checking Kubectl......................................" if ! command -v kubectl &> /dev/null then @@ -439,4 +452,4 @@ echo -e "${GREEN}This cluster has been set up with an etcd based on ephemeral${N echo -e "${GREEN}storage. It is suitable for evaluation purposes only - for${NC}" echo -e "${GREEN}production usage please see our etcd installation nodes at${NC}" echo -e "${GREEN}https://docs.storageos.com/docs/prerequisites/etcd/${NC}" - +echo From f0b7d72e392f7e9a7547b393f37ad095f73382a1 Mon Sep 17 00:00:00 2001 From: rovandep Date: Fri, 14 May 2021 09:24:20 +0200 Subject: [PATCH 12/14] refactoring deploy-storageos-cluster.sh and remove namespaces options --- sh/deploy-storageos-cluster.sh | 97 +++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 478850c29..79536fa2e 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -26,6 +26,7 @@ set -euo pipefail # most environments. # Getting the latest and greatest to deploy as a self-evaluation. +# Failing back to a manual entry if cURL not present (I know!). if ! command -v curl &> /dev/null then OPERATOR_VERSION='v2.4.0-rc.1' @@ -36,12 +37,11 @@ STORAGEOS_OPERATOR_LABEL='name=storageos-cluster-operator' STOS_NAMESPACE='kube-system' ETCD_NAMESPACE='storageos-etcd' STOS_CLUSTERNAME='self-evaluation' -while getopts c:n:e:v:l: option + +while getopts c:v:l: option do case "${option}" in c) STOS_CLUSTERNAME=${OPTARG};; - n) STOS_NAMESPACE=${OPTARG};; - e) ETCD_NAMESPACE=${OPTARG};; v) OPERATOR_VERSION=${OPTARG};; l) esac @@ -55,6 +55,7 @@ RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color +# Welcoming STORAGEOS users :) echo echo -e "${RED}Welcome to the ${NC}STORAGE${GREEN}OS${RED} self-evaluation installation script.${NC}" echo -e "${GREEN}Self-Evaluation guide: https://docs.storageos.com/docs/self-eval${NC}" @@ -64,18 +65,7 @@ echo # Checking and exiting if requirements are not met. echo -e "${GREEN}Checking requirements:${NC}" -echo -ne " Checking for exiting STORAGE${GREEN}OS${NC} cluster................" -if kubectl get storageoscluster --all-namespaces -o name &>/dev/null; -then - echo -ne "${RED}YES${NC}\n" - echo -e " ${RED}A ${NC}STORAGE${GREEN}OS ${NC}cluster${RED} is already installed on this Kubernetes cluster." - echo - exit - # todo: include a clean-up option from this breaking point -else - echo -ne ".${GREEN}NO${NC}\n" -fi - +# Checking if kubectl is present! echo -ne " Checking Kubectl......................................" if ! command -v kubectl &> /dev/null then @@ -87,20 +77,54 @@ then fi echo -ne ".${GREEN}OK${NC}\n" +# Checking for the minimum node count (3) echo -ne " Checking node count (minimum 3)......................." NODECOUNT=`kubectl get nodes -o name | wc -l` -if [ $NODECOUNT -lt 3 ] +if [ ${NODECOUNT} -lt 3 ] then - echo -e "${RED}NOK${NC}\n" + echo -ne "${RED}NOK${NC}\n" exit fi -echo -ne ".${GREEN}OK${NC}\n" +echo -ne ".${GREEN}OK${NC} (${NODECOUNT})\n" +# Checking for an existing STORAGEOS cluster on the kubernetes target +echo -ne " Checking for exiting STORAGE${GREEN}OS${NC} cluster................" +if kubectl get storageoscluster --all-namespaces -o name &>/dev/null; +then + echo -ne "${RED}YES${NC}\n" + echo -e " ${RED}/!\ ${NC}STORAGE${GREEN}OS ${NC}cluster${RED} already deployed on this Kubernetes cluster." + echo + exit + # todo: include a clean-up option from this breaking point +else + echo -ne ".${GREEN}NO${NC}\n" +fi + +# Summary of what is on the menu for deployment today echo echo -e "${GREEN}The script will deploy a ${NC}STORAGE${GREEN}OS cluster: ${NC}" echo -e " STORAGE${GREEN}OS${NC} cluster named ${RED}${STOS_CLUSTERNAME}${GREEN}.${NC}" -echo -e " STORAGE${GREEN}OS${NC} version ${RED}${STOS_VERSION}${GREEN} into namespace ${RED}${STOS_NAMESPACE}${GREEN}.${NC}" +echo -e " STORAGE${GREEN}OS${NC} version ${RED}${STOS_VERSION}${NC} into namespace ${RED}${STOS_NAMESPACE}${GREEN}.${NC}" + +# RC? Let's have a bit of a warning there +if [[ ${STOS_VERSION} =~ .*rc.* ]]; +then + echo -e " ${RED}/!\ ${STOS_VERSION}${NC}: Release Candidate are not intended for production deployment.${NC}" +fi +# not deploying in kube-system - brace yourself! +if [[ ! "${STOS_NAMESPACE}" == "kube-system" ]]; +then + echo -e " ${RED}/!\ ${NC}only ${RED}kube-system${NC} namespace namespace for ease of self-evualation.${NC}" + exit +fi + echo -e " etcd into namespace ${RED}${ETCD_NAMESPACE}${GREEN}.${NC}" +# not deploying in storageos-etcd - brace yourself! +if [[ ! "${ETCD_NAMESPACE}" == "storageos-etcd" ]]; +then + echo -e " ${RED}/!\ ${NC}only ${RED}storageos-etcd${NC} namespace for ease of self-evualation.${NC}" + exit +fi echo -e "${GREEN}The installation process will stop on any encountered error.${NC}" echo @@ -115,15 +139,13 @@ then echo -e "${RED}Install a ${NC}STORAGE${GREEN}OS${RED} Self-Evaluation cluster on Kubernetes.${NC}" echo echo -e " -c ${NC}STORAGE${GREEN}OS${NC} cluser name." - echo -e " -n Kubernetes namespace to install ${NC}STORAGE${GREEN}OS${NC} in." - echo -e " -e Kubernetes namespace to install ETCD in." echo -e " -v ${NC}STORAGE${GREEN}OS${NC} version to deploy." echo -e " Check https://github.com/storageos/cluster-operator/releases" echo - echo "Eg: ./deploy-storageos-cluster.sh -e my-etcd -n my-storageos -c demo-cluster -v ${STOS_VERSION}" - echo " curl -fsSL https://storageos.run | bash -s -- -e my-etcd -n my-storageos -c demo-cluster -v ${STOS_VERSION}" + echo "Eg: ./deploy-storageos-cluster.sh -c demo-cluster -v ${STOS_VERSION}" + echo " curl -fsSL https://storageos.run | bash -s -- -c demo-cluster -v ${STOS_VERSION}" echo - echo "Issues: " + echo "Issues: https://github.com/storageos/storageos.github.io" echo exit fi @@ -136,6 +158,18 @@ echo -ne " Is it OpenShift?......................................" if grep -q "openshift" <(kubectl get node --show-labels); then echo -ne "${GREEN}YES${NC}\n" + + # Checking if OCP CLI is present! + echo -ne " Checking OCP CLI......................................" + if ! command -v oc &> /dev/null + then + echo -ne "${RED}NOK${NC}\n" + echo -e "${RED} OCP CLI (oc) could not be found on this shell.${NC}" + echo -e "${RED} Please intall OCP CLI: https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/getting-started-cli.html/${NC}" + exit + fi + echo -ne ".${GREEN}OK${NC}\n" + echo -ne " OpenShift - adding SCC for ${RED}${ETCD_NAMESPACE}${GREEN}${NC} ............" oc adm policy add-scc-to-user anyuid \ system:serviceaccount:${ETCD_NAMESPACE}:default @@ -381,6 +415,18 @@ echo -ne ".${GREEN}OK${NC}\n" # install StorageOS itself. We default to the kube-system namespace, which # gives us some protection against eviction by the Kubelet under conditions of # contention. + +# interesting? if there is a STOS_NAMESPACE variable to mangle, should we not +# offer the capabilities; this is a testing environment, let's have users testing +# this. +# not deploying in kube-system - brace yourself! +if [[ ! "${STOS_NAMESPACE}" == "kube-system" ]]; +then + echo -ne " Creating STORAGE${GREEN}OS${NC} cluster namespace ${RED}${STOS_NAMESPACE}${NC}........" + kubectl create namespace ${STOS_NAMESPACE} 1>/dev/null + echo -ne ".${GREEN}OK${NC}\n" +fi + # In the StorageOS CR we declare the DNS name for the etcd deployment and # service we created earlier. echo -ne " Creating STORAGE${GREEN}OS${NC} cluster version ${RED}${STOS_VERSION}${NC}........" @@ -410,6 +456,7 @@ while ! grep -q "Running" <(echo "${phase}"); do sleep 10 phase="$(kubectl --namespace=${STOS_NAMESPACE} describe storageoscluster ${STOS_CLUSTERNAME})" done + echo -ne ".${GREEN}OK${NC}\n" # Now that we have a working StorageOS cluster, we can deploy a pod to run the @@ -417,7 +464,7 @@ echo -ne ".${GREEN}OK${NC}\n" # into this pod. echo -ne " Deploying STORAGE${GREEN}OS${NC} CLI as a pod......................" # Deploy the StorageOS CLI as a container -kubectl -n kube-system run \ +kubectl -n ${STOS_NAMESPACE} run \ --image storageos/cli:${CLI_VERSION} \ --restart=Never \ --env STORAGEOS_ENDPOINTS=storageos:5705 \ From 990f656e1aff915ac564d535ac1265385fccb725 Mon Sep 17 00:00:00 2001 From: rovandep Date: Fri, 14 May 2021 11:18:54 +0200 Subject: [PATCH 13/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 47 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 79536fa2e..74ab7ca26 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -183,9 +183,9 @@ echo -ne ".${GREEN}NO${NC}\n" # production deployments* but fine for evaluation purposes. The data in the # etcd will not persist outside of a reboot. -echo -ne " Creating etcd namespace ${RED}${ETCD_NAMESPACE}${NC}................." +echo -ne " Creating etcd namespace................................" kubectl create namespace ${ETCD_NAMESPACE} 1> /dev/null -echo -ne "${GREEN}OK${NC}\n" +echo -ne "${GREEN}OK${NC} (${RED}${ETCD_NAMESPACE}${NC})\n" echo -ne " Creating etcd ClusterRoleBinding......................" kubectl -n ${ETCD_NAMESPACE} create -f- 1>/dev/null</dev/null</dev/null -echo -ne ".${GREEN}OK${NC}\n" +echo -ne ".${GREEN}OK${NC} (${RED}${OPERATOR_VERSION}${NC})\n" # Wait for the operator to become ready @@ -422,14 +422,14 @@ echo -ne ".${GREEN}OK${NC}\n" # not deploying in kube-system - brace yourself! if [[ ! "${STOS_NAMESPACE}" == "kube-system" ]]; then - echo -ne " Creating STORAGE${GREEN}OS${NC} cluster namespace ${RED}${STOS_NAMESPACE}${NC}........" + echo -ne " Creating STORAGE${GREEN}OS${NC} cluster namespace........" kubectl create namespace ${STOS_NAMESPACE} 1>/dev/null - echo -ne ".${GREEN}OK${NC}\n" + echo -ne ".${GREEN}OK${NC} (${RED}${STOS_NAMESPACE}${NC})\n" fi # In the StorageOS CR we declare the DNS name for the etcd deployment and # service we created earlier. -echo -ne " Creating STORAGE${GREEN}OS${NC} cluster version ${RED}${STOS_VERSION}${NC}........" +echo -ne " Creating STORAGE${GREEN}OS${NC} cluster............................" kubectl create -f- 1>/dev/null</dev/null`; +do + spin done +echo -ne "${GREEN}OK${NC}\n" -echo -ne ".${GREEN}OK${NC}\n" # Now that we have a working StorageOS cluster, we can deploy a pod to run the # cli inside the cluster. When we want to access the cli, we can kubectl exec From b0c121c6eef20e6cbf70d2a7e62832a09efd7832 Mon Sep 17 00:00:00 2001 From: rovandep Date: Fri, 14 May 2021 13:30:24 +0200 Subject: [PATCH 14/14] refactoring deploy-storageos-cluster.sh --- sh/deploy-storageos-cluster.sh | 111 ++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 37 deletions(-) diff --git a/sh/deploy-storageos-cluster.sh b/sh/deploy-storageos-cluster.sh index 74ab7ca26..0b1b61e79 100755 --- a/sh/deploy-storageos-cluster.sh +++ b/sh/deploy-storageos-cluster.sh @@ -55,6 +55,16 @@ RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color +# spin the wheel to avoid nervous breakdown during waiting time +sp="/-\|" +spin() { + printf '\b%.1s' "$sp" + sp=${sp#?}${sp%???} +} +endspin() { + echo -ne '\b \b' +} + # Welcoming STORAGEOS users :) echo echo -e "${RED}Welcome to the ${NC}STORAGE${GREEN}OS${RED} self-evaluation installation script.${NC}" @@ -85,7 +95,7 @@ then echo -ne "${RED}NOK${NC}\n" exit fi -echo -ne ".${GREEN}OK${NC} (${NODECOUNT})\n" +echo -ne ".${GREEN}OK${NC} (${RED}${NODECOUNT}${NC})\n" # Checking for an existing STORAGEOS cluster on the kubernetes target echo -ne " Checking for exiting STORAGE${GREEN}OS${NC} cluster................" @@ -296,15 +306,15 @@ END echo -ne ".${GREEN}OK${NC}\n" # Wait for etcd operator to become ready -echo -ne " Waiting on etcd operator to be running................" -# sleep 5 -phase="$(kubectl -n ${ETCD_NAMESPACE} get pod -lname=etcd-operator --no-headers -ocustom-columns=status:.status.phase)" -while ! grep -q "Running" <(echo "${phase}"); do - sleep 2 - phase="$(kubectl -n ${ETCD_NAMESPACE} get pod -lname=etcd-operator --no-headers -ocustom-columns=status:.status.phase)" +echo -ne " Waiting on etcd operator to be running..............." +until phase=`kubectl -n ${ETCD_NAMESPACE} get pod -lname=etcd-operator --no-headers -ocustom-columns=status:.status.phase |grep -q "Running" 1>/dev/null`; +do + spin done +endspin echo -ne ".${GREEN}OK${NC}\n" + # Create etcd CustomResource # This will install 3 etcd pods into the cluster using ephemeral storage. It # will also create a service endpoint, by which we can refer to the cluster in @@ -374,15 +384,23 @@ echo -ne ".${GREEN}OK${NC} (${RED}${OPERATOR_VERSION}${NC})\n" # Wait for the operator to become ready -echo -ne " Waiting on STORAGE${GREEN}OS${NC} operator to be running..........." -phase="$(kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase)" -while ! grep -q "Running" <(echo "${phase}"); do - sleep 2 - phase="$(kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase)" +echo -ne " Waiting on STORAGE${GREEN}OS${NC} operator to be running.........." +# phase="$(kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase)" +# while ! grep -q "Running" <(echo "${phase}"); do +# sleep 2 +# phase="$(kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase)" +# done +# echo -ne ".${GREEN}OK${NC}\n" + +until phase=`kubectl -n storageos-operator get pod -l${STORAGEOS_OPERATOR_LABEL} --no-headers -ocustom-columns=status:.status.phase |grep -q "Running" 1>/dev/null`; +do + spin done +endspin echo -ne ".${GREEN}OK${NC}\n" + # The StorageOS secret contains credentials for our API, as well as CSI echo -ne " Creating STORAGE${GREEN}OS${NC} API secret........................." kubectl create -f- 1>/dev/null</dev/null</dev/null`; do spin done -echo -ne "${GREEN}OK${NC}\n" +endspin +echo -ne ".${GREEN}OK${NC}\n" # Now that we have a working StorageOS cluster, we can deploy a pod to run the # cli inside the cluster. When we want to access the cli, we can kubectl exec # into this pod. echo -ne " Deploying STORAGE${GREEN}OS${NC} CLI as a pod......................" -# Deploy the StorageOS CLI as a container -kubectl -n ${STOS_NAMESPACE} run \ ---image storageos/cli:${CLI_VERSION} \ ---restart=Never \ ---env STORAGEOS_ENDPOINTS=storageos:5705 \ ---env STORAGEOS_USERNAME=storageos \ ---env STORAGEOS_PASSWORD=storageos \ ---command cli \ --- /bin/sh -c "while true; do sleep 999999; done" \ -1>/dev/null +kubectl create -f- 1>/dev/null</dev/null`; +do + spin done +endspin echo -ne ".${GREEN}OK${NC}\n" echo echo -e "${GREEN}Your ${NC}STORAGE${GREEN}OS${NC} Cluster ${GREEN}now is up and running!" echo echo -e "${GREEN}Now would be a good time to deploy your first volume - see${NC}" -echo -e "${GREEN}https://docs.storageos.com/docs/self-eval/#a-namestorageosvolumeaprovision-a-storageos-volume${NC}" +echo -e "${GREEN} https://docs.storageos.com/docs/self-eval/#a-namestorageosvolumeaprovision-a-storageos-volume${NC}" echo -e "${GREEN}for an example of how to mount a StorageOS volume in a pod${NC}" echo -echo -e "${GREEN}Don't forget to license your cluster - see https://docs.storageos.com/docs/operations/licensing/${NC}" +echo -e "${GREEN}Get your Free Forever Developer license - see${NC}" +echo -e "${GREEN} https://docs.storageos.com/docs/operations/licensing/${NC}" +echo -e "${RED}A cluster can run unlicensed for 24 hours. Normal functioning of the cluster" +echo -e "${RED}can be unlocked by applying for a Free Forever Developer licence.${NC}" echo echo -e "${GREEN}This cluster has been set up with an etcd based on ephemeral${NC}" echo -e "${GREEN}storage. It is suitable for evaluation purposes only - for${NC}" echo -e "${GREEN}production usage please see our etcd installation nodes at${NC}" -echo -e "${GREEN}https://docs.storageos.com/docs/prerequisites/etcd/${NC}" +echo -e "${GREEN} https://docs.storageos.com/docs/prerequisites/etcd/${NC}" echo