Remove workarounds in ACM installation
[nonrtric/plt/rappmanager.git] / scripts / install / install-acm.sh
index 76362e0..7535c1f 100755 (executable)
@@ -2,6 +2,7 @@
 
 #  ============LICENSE_START===============================================
 #  Copyright (C) 2023 Nordix Foundation. All rights reserved.
+#  Copyright (C) 2023-2024 OpenInfra Foundation Europe. All rights reserved.
 #  ========================================================================
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -25,17 +26,44 @@ DISABLE_COMPONENTS=(policy-api policy-pap policy-apex-pdp policy-pdpd-cl policy-
 ACM_VALUES_FILE="docker/helm/policy/values.yaml"
 A1PMS_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-a1pms-ppnt/resources/config/A1pmsParticipantParameters.yaml"
 K8S_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-k8s-ppnt/values.yaml"
+K8S_VERSIONS_FILE="docker/compose/get-k8s-versions.sh"
+KAFKA_DIR="docker/helm/cp-kafka"
 
 IP_ADDRESS=$(hostname -I | awk '{print $1}')
 echo "IP Address : $IP_ADDRESS"
 
-git clone -b london "https://gerrit.onap.org/r/policy/docker"
+A1PMS_HOST=${A1PMS_HOST:-http://policymanagementservice.nonrtric:9080}
+CHART_REPO_HOST=${CHART_REPO_HOST:-'http://'$IP_ADDRESS':8879/charts'}
+
+function wait_for_pods_to_be_running() {
+    while [[ $TIME -lt 2000 ]]; do
+      NONRTRIC_PODS=$(kubectl get pods -n default --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers)
+      if [[ -z "$NONRTRIC_PODS" ]]; then
+        echo "All Components are running."
+        kubectl get pods -n default
+        break
+      fi
+
+      echo "Waiting for the below Components to be running..."
+      echo "$NONRTRIC_PODS"
+      TIME=$(expr $TIME + 5)
+      sleep 5
+    done
+}
+
+git clone "https://gerrit.onap.org/r/policy/docker"
 
 CWD=$(pwd)
 export WORKSPACE="$CWD/docker"
 
+# Kafka installation
+echo "Installing Confluent kafka"
+kubectl apply -f $KAFKA_DIR/zookeeper.yaml
+kubectl apply -f $KAFKA_DIR/kafka.yaml
+wait_for_pods_to_be_running
+
 echo "Updating policy docker image versions..."
-bash docker/compose/get-k8s-versions.sh
+bash $K8S_VERSIONS_FILE
 
 echo "Enabling the access for the clusterroles..."
 kubectl apply -f resources/acm-role-binding.yaml
@@ -51,10 +79,10 @@ for element in "${DISABLE_COMPONENTS[@]}"; do
 done
 
 echo "Updating A1PMS Participant"
-yq eval '.a1pms.baseUrl="http://policymanagementservice.nonrtric:9080"' -i $A1PMS_CONFIGURATION_FILE
+yq eval '.a1pms.baseUrl="'$A1PMS_HOST'"' -i $A1PMS_CONFIGURATION_FILE
 
 echo "Updating the k8s participant repo list"
-yq eval '.repoList.helm.repos += {"repoName":"local","address":"http://'$IP_ADDRESS':8879/charts"}' -i $K8S_CONFIGURATION_FILE
+yq eval '.repoList.helm.repos += {"repoName":"local","address":"'$CHART_REPO_HOST'"}' -i $K8S_CONFIGURATION_FILE
 
 echo "Building policy helm charts..."
 helm dependency build docker/helm/policy/
@@ -62,19 +90,6 @@ helm dependency build docker/helm/policy/
 echo "Installing policy helm charts..."
 helm install csit-policy docker/helm/policy/ -n default
 
-while [[ $TIME -lt 2000 ]]; do
-  NONRTRIC_PODS=$(kubectl get pods -n default --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers)
-  if [[ -z "$NONRTRIC_PODS" ]]; then
-    echo "All ACM Components are running."
-    kubectl get pods -n default
-    break
-  fi
-
-  echo "Waiting for ACM Components to be running..."
-  echo "These pods are not running"
-  echo "$NONRTRIC_PODS"
-  TIME=$(expr $TIME + 5)
-  sleep 5
-done
+wait_for_pods_to_be_running
 
-echo "ACM Components Installation Completed."
\ No newline at end of file
+echo "ACM Components Installation Completed."