Enabling helm3 & kubernetes 1.18 for RIC in shell scripts without breaking existing... 32/5032/7
authorAlok Bhatt <alok_bh@hcl.com>
Wed, 11 Nov 2020 04:46:58 +0000 (04:46 +0000)
committerZhe Huang <zhehuang@research.att.com>
Wed, 2 Dec 2020 00:26:55 +0000 (00:26 +0000)
Issue-ID: RIC-678

Signed-off-by: Alok Bhatt <alok_bh@hcl.com>
Change-Id: Ibc1821aac0e91998117fc1f698008d7281f04dc4

bin/prepare-common-templates
bin/verify-ric-charts
ci/Dockerfile
tools/k8s/etc/infra.rc
tools/k8s/heat/parts/part-1-v6.yaml
tools/k8s/heat/parts/part-1.yaml
tools/k8s/heat/scripts/k8s_vm_aux_install.sh
tools/k8s/heat/scripts/k8s_vm_install.sh

index d791e22..255c32d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -x
 ################################################################################
 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
 #   Copyright (c) 2019 Nokia.                                                  #
 
 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
 
+#Check for helm3
+IS_HELM3=$(helm version --short|grep -e "^v3")
+
 # Start Helm local repo if there isn't one
 HELM_REPO_PID=$(ps -x | grep  "helm serve" | grep -v "grep" | awk '{print $1}')
-if [ -z "$HELM_REPO_PID" ]; then
-    nohup helm serve >& /dev/null &
-fi
-
 
+if [ -z "$HELM_REPO_PID" ]
+then
+    if [ -z $IS_HELM3 ]
+    then
+      nohup helm serve >& /dev/null &
+    else
+      nohup helm servecm --port=8879 --context-path=/charts  --storage local >& /dev/null &
+    fi
+fi
 
 # Package common templates and serve it using Helm local repo
-HELM_HOME=$(helm home)
+if [ $IS_HELM3 ]
+then 
+  eval $(helm env |grep HELM_REPOSITORY_CACHE)
+  HELM_LOCAL_REPO="${HELM_REPOSITORY_CACHE}/local/"
+  mkdir -p $HELM_LOCAL_REPO
+else 
+  HELM_HOME=$(helm home)
+  HELM_LOCAL_REPO="${HELM_HOME}/repository/local/"
+fi
+
 COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
-cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
 AUX_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/aux-common/Chart.yaml | grep version | awk '{print $2}')
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/aux-common
-cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
 NONRTRIC_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
-cp /tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+cp /tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
-helm repo index $HELM_HOME/repository/local/
+helm repo index $HELM_LOCAL_REPO
 
 
 # Make sure that helm local repo is added
index 9449837..e9feb06 100755 (executable)
 OVERRIDEYAML=$1
 
 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
+#Check for helm3
+IS_HELM3=$(helm version --short|grep -e "^v3")
 
 # Start Helm local repo if there isn't one
 HELM_REPO_PID=$(ps -x | grep  "helm serve" | grep -v "grep" | awk '{print $1}')
-if [ -z "$HELM_REPO_PID" ]; then
-    nohup helm serve >& /dev/null &
+if [ -z "$HELM_REPO_PID" ]
+then
+    if [ -z $IS_HELM3 ]
+    then
+      nohup helm serve >& /dev/null &
+    else
+      nohup helm servecm --port=8879 --context-path=/charts  --storage local >& /dev/null &
+    fi
 fi
 
 echo "Package ric-common and serve it using Helm local repo"
+# Package common templates and serve it using Helm local repo
+HELM_LOCAL_REPO=""
+if [ $IS_HELM3 ]
+then
+  eval $(helm env |grep HELM_REPOSITORY_CACHE)
+  HELM_LOCAL_REPO="${HELM_REPOSITORY_CACHE}/local/"
+else
+  HELM_HOME=$(helm home)
+  HELM_LOCAL_REPO="${HELM_HOME}/repository/local/"
+fi
+
 HELM_HOME=$(helm home)
 COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/ric-common
-cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
 AUX_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/aux-common/Chart.yaml | grep version | awk '{print $2}')
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/aux-common
-cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
 NONRTRIC_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
-cp /tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $HELM_HOME/repository/local/
+cp /tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
 
 
index 9479b73..c1080e0 100644 (file)
@@ -17,7 +17,7 @@
 ##############################################################################
 
 FROM ubuntu:18.04
-RUN apt-get update && apt-get -y install curl
+RUN apt-get update && apt-get -y install curl ca-certificates
 ARG GH=get_helm.sh
 # often times out during LF jenkins build
 RUN curl --silent --show-error --connect-timeout 10 --retry 6 -L https://raw.githubusercontent.com/helm/helm/master/scripts/get -o ${GH}
index 1e90a93..06f16b2 100644 (file)
@@ -1,8 +1,8 @@
 # modify below for RIC infrastructure (docker-k8s-helm) component versions
 # RIC tested
 INFRA_DOCKER_VERSION=""
-INFRA_HELM_VERSION="2.12.3"
-INFRA_K8S_VERSION="1.16.0"
+INFRA_HELM_VERSION="3.2.3"
+INFRA_K8S_VERSION="1.18.3"
 INFRA_CNI_VERSION="0.7.5"
 # older RIC tested
 #INFRA_DOCKER_VERSION=""
index e24f753..da97977 100644 (file)
@@ -48,7 +48,7 @@ parameters:
 
   k8s_version:
     type: string
-    default: "1.13.3"
+    default: "1.18.3"
 
   k8s_cni_version:
     type: string
@@ -56,7 +56,7 @@ parameters:
 
   helm_version:
     type: string
-    default: "2.12.3"
+    default: "3.2.3"
 
   helm_deploy_delay:
     type: string
index a0ff0eb..fa08320 100644 (file)
@@ -64,7 +64,7 @@ parameters:
 
   k8s_version:
     type: string
-    default: "1.13.3"
+    default: "1.18.3"
 
   k8s_cni_version:
     type: string
@@ -72,7 +72,7 @@ parameters:
 
   helm_version:
     type: string
-    default: "2.12.3"
+    default: "3.2.3"
 
   helm_deploy_delay:
     type: string
index 4ee6d32..b14302a 100644 (file)
@@ -25,25 +25,31 @@ kubectl create namespace "${LOGGING_NS}"
 while ! helm repo add incubator "https://kubernetes-charts-incubator.storage.googleapis.com/"; do
   sleep 10
 done
+IS_HELM3=$(helm version --short|grep -e "^v3")
+HELM_FLAG='--name'
+if [ -z $IS_HELM3 ]
+   HELM_FLAG=""
+fi
+
 helm repo update
-helm install incubator/elasticsearch \
+helm install ${HELM_FLAG} elasticsearch \
    --namespace "${LOGGING_NS}" \
-   --name elasticsearch \
    --set image.tag=6.7.0 \
    --set data.terminationGracePeriodSeconds=0 \
    --set master.persistence.enabled=false \
-   --set data.persistence.enabled=false
-helm install stable/fluentd-elasticsearch \
-   --name fluentd \
+   --set data.persistence.enabled=false \
+   incubator/elasticsearch 
+helm install ${HELM_FLAG} fluentd \
    --namespace "${LOGGING_NS}" \
    --set elasticsearch.host=elasticsearch-client.${LOGGING_NS}.svc.cluster.local \
-   --set elasticsearch.port=9200
-helm install stable/kibana \
-   --name kibana \
+   --set elasticsearch.port=9200 \
+   stable/fluentd-elasticsearch
+helm install ${HELM_FLAG} kibana \
    --namespace "${LOGGING_NS}" \
    --set env.ELASTICSEARCH_URL=http://elasticsearch-client.${LOGGING_NS}.svc.cluster.local:9200 \
    --set env.ELASTICSEARCH_HOSTS=http://elasticsearch-client.${LOGGING_NS}.svc.cluster.local:9200 \
-   --set env.SERVER_BASEPATH=/api/v1/namespaces/${LOGGING_NS}/services/kibana/proxy
+   --set env.SERVER_BASEPATH=/api/v1/namespaces/${LOGGING_NS}/services/kibana/proxy \
+   stable/kibana
    #--set image.tag=6.4.2 \
 
 KIBANA_POD_NAME=$(kubectl get pods --selector=app=kibana -n  "${LOGGING_NS}" \
@@ -55,7 +61,7 @@ wait_for_pods_running 1 "${LOGGING_NS}" "${KIBANA_POD_NAME}"
 PROMETHEUS_NS="monitoring"
 OPERATOR_POD_NAME="prometheus-prometheus-operator-prometheus-0"
 ALERTMANAGER_POD_NAME="alertmanager-prometheus-operator-alertmanager-0"
-helm install stable/prometheus-operator --name prometheus-operator --namespace "${PROMETHEUS_NS}"
+helm install ${HELM_FLAG} prometheus-operator  --namespace "${PROMETHEUS_NS}" stable/prometheus-operator
 wait_for_pods_running 1 "${PROMETHEUS_NS}" "${OPERATOR_POD_NAME}"
 
 GRAFANA_POD_NAME=$(kubectl get pods --selector=app=grafana -n  "${PROMETHEUS_NS}" \
index 6f20ea2..ee98acf 100644 (file)
@@ -16,7 +16,7 @@
 ################################################################################
 
 
-# first parameter: number of expected running pods
+# first parameter: number of expected running  pods
 # second parameter: namespace (all-namespaces means all namespaces)
 # third parameter: [optional] keyword
 wait_for_pods_running () {
@@ -259,7 +259,7 @@ apiVersion: kubeproxy.config.k8s.io/v1alpha1
 kind: KubeProxyConfiguration
 mode: ipvs
 EOF
-  elif [[ ${KUBEV} == 1.15.* ]] || [[ ${KUBEV} == 1.16.* ]]; then
+  elif [[ ${KUBEV} == 1.15.* ]] || [[ ${KUBEV} == 1.16.* ]] || [[ ${KUBEV} == 1.18.* ]]; then
     cat <<EOF >/root/config.yaml
 apiVersion: kubeadm.k8s.io/v1beta2
 kubernetesVersion: v${KUBEV}
@@ -333,7 +333,7 @@ EOF
   HELMV=$(cat /opt/config/helm_version.txt)
   HELMVERSION=${HELMV}
   if [ ! -e helm-v${HELMVERSION}-linux-amd64.tar.gz ]; then
-    wget https://storage.googleapis.com/kubernetes-helm/helm-v${HELMVERSION}-linux-amd64.tar.gz
+    wget https://get.helm.sh/helm-v${HELMVERSION}-linux-amd64.tar.gz
   fi
   cd /root && rm -rf Helm && mkdir Helm && cd Helm
   tar -xvf ../helm-v${HELMVERSION}-linux-amd64.tar.gz
@@ -341,21 +341,29 @@ EOF
 
   cd /root
   # install RBAC for Helm
-  kubectl create -f rbac-config.yaml
+  if [[ ${HELMVERSION} == 2.* ]]; then
+     kubectl create -f rbac-config.yaml
+  fi
 
   rm -rf /root/.helm
   if [[ ${KUBEV} == 1.16.* ]]; then
     # helm init uses API extensions/v1beta1 which is depreciated by Kubernetes
     # 1.16.0.  Until upstream (helm) provides a fix, this is the work-around.
-    helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml > /tmp/helm-init.yaml
-    sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' /tmp/helm-init.yaml > /tmp/helm-init-patched.yaml
-    kubectl apply -f /tmp/helm-init-patched.yaml
+    if [[ ${HELMVERSION} == 2.* ]]; then
+       helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml > /tmp/helm-init.yaml
+       sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' /tmp/helm-init.yaml > /tmp/helm-init-patched.yaml
+       kubectl apply -f /tmp/helm-init-patched.yaml
+    fi
   else
-    helm init --service-account tiller
+    if [[ ${HELMVERSION} == 2.* ]]; then
+       helm init --service-account tiller
+    fi
+  fi
+  if [[ ${HELMVERSION} == 2.* ]]; then
+     helm init -c
+     export HELM_HOME="$(pwd)/.helm"
+     echo "HELM_HOME=${HELM_HOME}" >> /etc/environment
   fi
-  helm init -c
-  export HELM_HOME="$(pwd)/.helm"
-  echo "HELM_HOME=${HELM_HOME}" >> /etc/environment
 
   # waiting for tiller pod to be in running state
   while ! helm version; do