3 # ============LICENSE_START===============================================
4 # Copyright (C) 2023 Nordix Foundation. All rights reserved.
5 # Copyright (C) 2023-2024 OpenInfra Foundation Europe. All rights reserved.
6 # ========================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=================================================
21 echo "######### Installing ACM components #########"
23 ENABLE_COMPONENTS=(policy-models-simulator policy-clamp-runtime-acm policy-clamp-ac-kserve-ppnt policy-clamp-ac-k8s-ppnt policy-clamp-ac-a1pms-ppnt)
24 DISABLE_COMPONENTS=(policy-api policy-pap policy-apex-pdp policy-pdpd-cl policy-xacml-pdp policy-distribution policy-clamp-ac-pf-ppnt policy-clamp-ac-http-ppnt)
26 ACM_VALUES_FILE="docker/helm/policy/values.yaml"
27 A1PMS_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-a1pms-ppnt/resources/config/A1pmsParticipantParameters.yaml"
28 K8S_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-k8s-ppnt/values.yaml"
29 K8S_VERSIONS_FILE="docker/compose/get-k8s-versions.sh"
30 KAFKA_DIR="docker/helm/cp-kafka"
32 IP_ADDRESS=$(hostname -I | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 | awk '{print $1}')
33 echo "IP Address : $IP_ADDRESS"
35 A1PMS_HOST=${A1PMS_HOST:-http://policymanagementservice.nonrtric:9080}
36 CHART_REPO_GET_URI=${CHART_REPO_GET_URI:-'http://'$IP_ADDRESS':8879/charts'}
38 function wait_for_pods_to_be_running() {
39 while [[ $TIME -lt 2000 ]]; do
40 NONRTRIC_PODS=$(kubectl get pods -n default --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers)
41 if [[ -z "$NONRTRIC_PODS" ]]; then
42 echo "All Components are running."
43 kubectl get pods -n default
47 echo "Waiting for the below Components to be running..."
49 TIME=$(expr $TIME + 5)
54 git clone "https://gerrit.onap.org/r/policy/docker"
57 export WORKSPACE="$CWD/docker"
60 echo "Installing Confluent kafka"
61 # Using "default" as namespace for kafka installation. As the policy CSIT helm charts contains the namespace "default" inbuilt.
62 # ACM installation fails to run, If the kubernetes cluster setup with a different default namespace,
63 # Expected kafka service is "kafka.default.svc.cluster.local"
64 # This can be removed when the kafka charts provided with "default" namespace or when policy CSIT charts can be configurable with different namespace.
65 kubectl apply -f $KAFKA_DIR/zookeeper.yaml -n default
66 kubectl apply -f $KAFKA_DIR/kafka.yaml -n default
67 wait_for_pods_to_be_running
69 echo "Updating policy docker image versions..."
70 bash $K8S_VERSIONS_FILE
72 echo "Enabling the access for the clusterroles..."
73 kubectl apply -f resources/acm-role-binding.yaml
75 for element in "${ENABLE_COMPONENTS[@]}"; do
76 echo "Enabling component $element"
77 yq eval ".$element.enabled"="true" -i $ACM_VALUES_FILE
80 for element in "${DISABLE_COMPONENTS[@]}"; do
81 echo "Disabling component $element"
82 yq eval ".$element.enabled"="false" -i $ACM_VALUES_FILE
85 echo "Updating A1PMS Participant"
86 yq eval '.a1pms.baseUrl="'$A1PMS_HOST'"' -i $A1PMS_CONFIGURATION_FILE
88 echo "Updating the k8s participant repo list"
89 yq eval '.repoList.helm.repos += {"repoName":"local","address":"'$CHART_REPO_GET_URI'"}' -i $K8S_CONFIGURATION_FILE
91 echo "Building policy helm charts..."
92 helm dependency build docker/helm/policy/
94 echo "Installing policy helm charts..."
95 helm install csit-policy docker/helm/policy/ -n default
97 wait_for_pods_to_be_running
99 echo "ACM Components Installation Completed."