alarmadapter helm renamed to alarmmanager
[ric-plt/ric-dep.git] / bin / install
index bc9a4ba..6f4fbd4 100755 (executable)
@@ -61,6 +61,8 @@ function wait_for_cats() {
   echo
 }
 
+KERNEL_OPTIMIZATION=false
+IS_HELM3=$(helm version --short|grep -e "^v3")
 
 while [ -n "$1" ]; do # while loop starts
 
@@ -72,6 +74,8 @@ while [ -n "$1" ]; do # while loop starts
     -c) LIST_OF_COMPONENTS=$2
         shift
         ;;
+    -o) KERNEL_OPTIMIZATION=true
+        ;;
     *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
 
     esac
@@ -89,7 +93,12 @@ if [ -z "$OVERRIDEYAML" ];then
     exit 1
 fi
 
-HAS_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common)
+if [ -z $IS_HELM3 ]
+then
+  HAS_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common)
+else 
+  HAS_COMMON_PACKAGE=$(helm search repo local/ric-common | grep ric-common)
+fi
 
 if [ -z "$HAS_COMMON_PACKAGE" ];then
     echo "****************************************************************************************************************"
@@ -110,7 +119,7 @@ RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
 LOCAL_REPOSITORY=$(echo "$COMMON_BLOCK" | awk '/^ *localregistry:/{print $2}')
 
 # replace the dbaasha with dbaas1 if deploying non HA DBaaS
-COMPONENTS=${LIST_OF_COMPONENTS:-"infrastructure dbaas xapp-onboarder appmgr rtmgr e2mgr e2term a1mediator submgr vespamgr jaegeradapter o1mediator alarmadapter"}
+COMPONENTS=${LIST_OF_COMPONENTS:-"infrastructure dbaas xapp-onboarder appmgr rtmgr e2mgr e2term a1mediator submgr vespamgr jaegeradapter o1mediator alarmmanager"}
 echo "Deploying RIC infra components [$COMPONENTS]"
 
 
@@ -134,7 +143,97 @@ if [ ! -z "$LOCAL_REPOSITORY" ]; then
 fi
 
 
+echo Add cluster roles
+    cat >ricplt-role.yaml <<EOF
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRole
+metadata:
+  name: ricplt-system-tiller
+rules:
+  - apiGroups: [""]
+    resources: ["deployments"]
+    verbs: ["get", "list", "create", "delete"]
+  - apiGroups: ["apiextensions.k8s.io"]
+    resources: ["customresourcedefinitions"]
+    verbs: ["get", "list", "create", "delete"]
+  - apiGroups: ["rbac.authorization.k8s.io"]
+    resources: ["clusterroles", "clusterrolebindings"]
+    verbs: ["get", "list", "create", "delete"]
+  - apiGroups: [""]
+    resources: ["events"]
+    verbs: ["create", "patch"]
+  - apiGroups: [""]
+    resources: ["nodes"]
+    verbs: ["list", "watch", "get"]
+  - apiGroups: [""]
+    resources: ["nodes/metrics"]
+    verbs: ["list", "watch", "get"]
+  - apiGroups: [""]
+    resources: ["nodes/proxy"]
+    verbs: ["list", "watch", "get"]
+  - apiGroups: ["configuration.konghq.com"]
+    resources: ["kongconsumers"]
+    verbs: ["get", "list", "watch"]
+  - apiGroups: ["configuration.konghq.com"]
+    resources: ["kongcredentials"]
+    verbs: ["get", "list", "watch"]
+  - apiGroups: ["configuration.konghq.com"]
+    resources: ["kongingresses"]
+    verbs: ["get", "list", "watch"]
+  - apiGroups: ["configuration.konghq.com"]
+    resources: ["kongplugins"]
+    verbs: ["get", "list", "watch"]
+  - apiGroups: ["networking.k8s.io"]
+    resources: ["ingresses"]
+    verbs: ["watch", "list", "get", "create", "delete", "update"]
+  - apiGroups: [""]
+    resources: ["ingresses"]
+    verbs: ["watch", "list", "get", "create", "delete", "update"]
+  - apiGroups: [""]
+    resources: ["persistentvolumes"]
+    verbs: ["watch", "list", "get", "create", "delete"]
+  - apiGroups: ["danm.k8s.io"]
+    resources: ["clusternetworks"]
+    verbs: ["watch", "list", "get", "create", "delete"]
+  - apiGroups: ["extensions"]
+    resources: ["ingresses/status"]
+    verbs: ["update", "get", "list", "watch"]
+  - apiGroups: ["networking.k8s.io"]
+    resources: ["ingresses/status"]
+    verbs: ["update", "get", "list", "watch"]
+  - apiGroups: ["certificates.k8s.io"]
+    resources: ["certificatesigningrequests"]
+    verbs: ["list", "watch"]
+  - apiGroups: ["storage.k8s.io"]
+    resources: ["storageclasses"]
+    verbs: ["list", "watch"]
+  - nonResourceURLs: ["/metrics"]
+    verbs: ["get"]
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  name: ricplt-system-tiller
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: ClusterRole
+  name: ricplt-system-tiller
+subjects:
+  - kind: ServiceAccount
+    name: tiller
+    namespace: kube-system
+EOF
+
+if [ -z $IS_HELM3 ]
+then
+   kubectl apply -f ricplt-role.yaml
+   rm ricplt-role.yaml
+fi
+
+
 # Add kernel optimization for radis services
+if $KERNEL_OPTIMIZATION; then
     cat >kernel_optimizer.yaml <<EOF
 apiVersion: apps/v1
 kind: DaemonSet
@@ -184,12 +283,18 @@ wait_for_pods redis-kernel-optimizer ${INFRANAMESPACE:-ricinfra}
 wait_for_cats redis-kernel-optimizer ${INFRANAMESPACE:-ricinfra}
 kubectl delete -f kernel_optimizer.yaml
 rm kernel_optimizer.yaml
+fi
 
 
 for component in $COMPONENTS; do
     helm dep up $DIR/../helm/$component
-    helm install -f $OVERRIDEYAML --namespace "${PLTNAMESPACE:-ricplt}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
-    sleep 3
+    COMPONENT="${RELEASE_PREFIX}-$component"
+    if [ -z $IS_HELM3 ]
+    then
+      COMPONENT=" --name $COMPONENT"
+    fi
+    helm install -f $OVERRIDEYAML --namespace "${PLTNAMESPACE:-ricplt}" $COMPONENT $DIR/../helm/$component
+    sleep 8
 done