From e6888c114de9296368fe4d32cc18041e4fe0de75 Mon Sep 17 00:00:00 2001 From: mhuseinbasic Date: Sun, 15 Mar 2020 07:29:15 +0100 Subject: [PATCH 1/5] add helm version check to gke_bootstrap_script --- scripts/gke_bootstrap_script.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/gke_bootstrap_script.sh b/scripts/gke_bootstrap_script.sh index e792083fbd..d23864c166 100755 --- a/scripts/gke_bootstrap_script.sh +++ b/scripts/gke_bootstrap_script.sh @@ -32,6 +32,8 @@ function bootstrap(){ set -e validate_required_tools; + HELM_VERSION="$(helm version --short)" + # Use the default cluster version for the specified zone if not provided if [ -z "${CLUSTER_VERSION}" ]; then CLUSTER_VERSION=$(gcloud container get-server-config --zone $ZONE --project $PROJECT --format='value(defaultClusterVersion)'); @@ -81,7 +83,13 @@ function bootstrap(){ kubectl --namespace=kube-system wait --for=condition=Available --timeout=5m apiservices/v1beta1.metrics.k8s.io echo "Installing helm..." - helm init --wait --service-account tiller + + if [[ $HELM_VERSION == v3* ]]; then + helm repo add stable https://kubernetes-charts.storage.googleapis.com/ + else + helm init --wait --service-account tiller + fi + helm repo update if ! ${USE_STATIC_IP}; then -- GitLab From 4e56e11ce677ef714b0092fefbfd8733f8fe1c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhamed=20Huseinba=C5=A1i=C4=87?= Date: Thu, 19 Mar 2020 08:20:28 +0000 Subject: [PATCH 2/5] Apply suggestion to scripts/gke_bootstrap_script.sh --- scripts/gke_bootstrap_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/gke_bootstrap_script.sh b/scripts/gke_bootstrap_script.sh index d23864c166..a1061731d8 100755 --- a/scripts/gke_bootstrap_script.sh +++ b/scripts/gke_bootstrap_script.sh @@ -32,7 +32,8 @@ function bootstrap(){ set -e validate_required_tools; - HELM_VERSION="$(helm version --short)" + helm version --short --client | grep -q '^v3\.[0-9]+' + IS_HELM_3=$? # Use the default cluster version for the specified zone if not provided if [ -z "${CLUSTER_VERSION}" ]; then -- GitLab From 900df64ab2c25e57b3697c2993a36d7944b148aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhamed=20Huseinba=C5=A1i=C4=87?= Date: Thu, 19 Mar 2020 08:21:15 +0000 Subject: [PATCH 3/5] Apply suggestion to scripts/gke_bootstrap_script.sh --- scripts/gke_bootstrap_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gke_bootstrap_script.sh b/scripts/gke_bootstrap_script.sh index a1061731d8..9e852a4042 100755 --- a/scripts/gke_bootstrap_script.sh +++ b/scripts/gke_bootstrap_script.sh @@ -85,7 +85,7 @@ function bootstrap(){ echo "Installing helm..." - if [[ $HELM_VERSION == v3* ]]; then + if $IS_HELM_3 ; then helm repo add stable https://kubernetes-charts.storage.googleapis.com/ else helm init --wait --service-account tiller -- GitLab From 33d9c2f2176871c86d30bd0b496eb7ffeabaa381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhamed=20Huseinba=C5=A1i=C4=87?= Date: Thu, 19 Mar 2020 08:21:31 +0000 Subject: [PATCH 4/5] Apply suggestion to scripts/gke_bootstrap_script.sh --- scripts/gke_bootstrap_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gke_bootstrap_script.sh b/scripts/gke_bootstrap_script.sh index 9e852a4042..aae01c9f7b 100755 --- a/scripts/gke_bootstrap_script.sh +++ b/scripts/gke_bootstrap_script.sh @@ -68,7 +68,7 @@ function bootstrap(){ gcloud container clusters get-credentials $CLUSTER_NAME --zone $ZONE --project $PROJECT; # Create roles for RBAC Helm - if $RBAC_ENABLED; then + if $RBAC_ENABLED && $IS_HELM_3 ; then status_code=$(curl -L -w '%{http_code}' -o rbac-config.yaml -s "https://gitlab.com/gitlab-org/charts/gitlab/raw/master/doc/installation/examples/rbac-config.yaml"); if [ "$status_code" != 200 ]; then echo "Failed to download rbac-config.yaml, status code: $status_code"; -- GitLab From a0d83ef6d7015fcf9e1fe9b87bbf241353f97750 Mon Sep 17 00:00:00 2001 From: mhuseinbasic Date: Thu, 19 Mar 2020 20:49:28 +0100 Subject: [PATCH 5/5] improve helm version check regex in bootstrap script --- scripts/gke_bootstrap_script.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/gke_bootstrap_script.sh b/scripts/gke_bootstrap_script.sh index aae01c9f7b..ebe3edbff4 100755 --- a/scripts/gke_bootstrap_script.sh +++ b/scripts/gke_bootstrap_script.sh @@ -32,8 +32,10 @@ function bootstrap(){ set -e validate_required_tools; - helm version --short --client | grep -q '^v3\.[0-9]+' + set +e + helm version --short --client | grep -q '^v3\.[0-9]\{1,\}' IS_HELM_3=$? + set -e # Use the default cluster version for the specified zone if not provided if [ -z "${CLUSTER_VERSION}" ]; then @@ -68,7 +70,7 @@ function bootstrap(){ gcloud container clusters get-credentials $CLUSTER_NAME --zone $ZONE --project $PROJECT; # Create roles for RBAC Helm - if $RBAC_ENABLED && $IS_HELM_3 ; then + if $RBAC_ENABLED && [ ! $IS_HELM_3 -eq 0 ]; then status_code=$(curl -L -w '%{http_code}' -o rbac-config.yaml -s "https://gitlab.com/gitlab-org/charts/gitlab/raw/master/doc/installation/examples/rbac-config.yaml"); if [ "$status_code" != 200 ]; then echo "Failed to download rbac-config.yaml, status code: $status_code"; @@ -85,7 +87,7 @@ function bootstrap(){ echo "Installing helm..." - if $IS_HELM_3 ; then + if [ $IS_HELM_3 -eq 0 ]; then helm repo add stable https://kubernetes-charts.storage.googleapis.com/ else helm init --wait --service-account tiller -- GitLab