Bug 1878 Speed up Artifactory search
[osm/devops.git] / installers / install_kubeadm_cluster.sh
index c0f067a..84a4872 100755 (executable)
@@ -18,7 +18,8 @@ set +eux
 #installs kubernetes packages
 function install_kube() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
-    K8S_VERSION=1.20.11-00
+    K8S_VERSION=1.20.14-00
+    # Kubernetes releases can be found here: https://kubernetes.io/releases/
     # To check other available versions, run the following command
     # curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}'
     sudo apt-get update && sudo apt-get install -y apt-transport-https
@@ -57,7 +58,8 @@ function deploy_cni_provider() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     CNI_DIR="$(mktemp -d -q --tmpdir "flannel.XXXXXX")"
     trap 'rm -rf "${CNI_DIR}"' EXIT
-    wget -q https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml -P $CNI_DIR
+    wget --retry-on-host-error --retry-on-http-error 404,429,503 --tries=5 https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml -P $CNI_DIR
+    [ ! -f $CNI_DIR/kube-flannel.yml ] && FATAL "Cannot Install Flannel because $CNI_DIR/kube-flannel.yml was not found. Maybe the file https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml is temporarily not accessible"
     kubectl apply -f $CNI_DIR
     [ $? -ne 0 ] && FATAL "Cannot Install Flannel"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
@@ -73,20 +75,23 @@ function taint_master_node() {
 }
 
 #Install Helm v3
+#Helm releases can be found here: https://github.com/helm/helm/releases
 function install_helm() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
-    helm > /dev/null 2>&1
-    if [ $? != 0 ] ; then
+    HELM_VERSION="v3.7.2"
+    if ! [[ "$(helm version --short 2>/dev/null)" =~ ^v3.* ]]; then
         # Helm is not installed. Install helm
-        echo "Helm is not installed, installing ..."
-        curl https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz --output helm-v3.6.3.tar.gz
-        tar -zxvf helm-v3.6.3.tar.gz
+        echo "Helm3 is not installed, installing ..."
+        curl https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz --output helm-${HELM_VERSION}.tar.gz
+        tar -zxvf helm-${HELM_VERSION}.tar.gz
         sudo mv linux-amd64/helm /usr/local/bin/helm
         rm -r linux-amd64
-        rm helm-v3.6.3.tar.gz
-        helm repo add stable https://charts.helm.sh/stable
-        helm repo update
+        rm helm-${HELM_VERSION}.tar.gz
+    else
+        echo "Helm3 is already installed. Skipping installation..."
     fi
+    helm repo add stable https://charts.helm.sh/stable
+    helm repo update
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
@@ -225,7 +230,7 @@ function check_for_readiness() {
 #removes osm deployments and services
 function remove_k8s_namespace() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
-    kubectl delete ns $1
+    kubectl delete ns $1 2>&1 >/dev/null
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }