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"
56 git fetch https://gerrit.onap.org/r/policy/docker refs/changes/46/137546/1 && git checkout FETCH_HEAD
60 export WORKSPACE="$CWD/docker"
63 echo "Installing Confluent kafka"
64 # Using "default" as namespace for kafka installation. As the policy CSIT helm charts contains the namespace "default" inbuilt.
65 # ACM installation fails to run, If the kubernetes cluster setup with a different default namespace,
66 # Expected kafka service is "kafka.default.svc.cluster.local"
67 # This can be removed when the kafka charts provided with "default" namespace or when policy CSIT charts can be configurable with different namespace.
68 kubectl apply -f $KAFKA_DIR/zookeeper.yaml -n default
69 kubectl apply -f $KAFKA_DIR/kafka.yaml -n default
70 wait_for_pods_to_be_running
72 echo "Updating policy docker image versions..."
73 bash $K8S_VERSIONS_FILE
75 echo "Enabling the access for the clusterroles..."
76 kubectl apply -f resources/acm-role-binding.yaml
78 for element in "${ENABLE_COMPONENTS[@]}"; do
79 echo "Enabling component $element"
80 yq eval ".$element.enabled"="true" -i $ACM_VALUES_FILE
83 for element in "${DISABLE_COMPONENTS[@]}"; do
84 echo "Disabling component $element"
85 yq eval ".$element.enabled"="false" -i $ACM_VALUES_FILE
88 echo "Updating A1PMS Participant"
89 yq eval '.a1pms.baseUrl="'$A1PMS_HOST'"' -i $A1PMS_CONFIGURATION_FILE
91 echo "Updating the k8s participant repo list"
92 yq eval '.repoList.helm.repos += {"repoName":"local","address":"'$CHART_REPO_GET_URI'"}' -i $K8S_CONFIGURATION_FILE
94 echo "Building policy helm charts..."
95 helm dependency build docker/helm/policy/
97 echo "Installing policy helm charts..."
98 helm install csit-policy docker/helm/policy/ -n default
100 wait_for_pods_to_be_running
102 echo "ACM Components Installation Completed."