blob: 1008b56cfe7acee639a23bb5d7884e9e4b5b7532 [file] [log] [blame]
aravind.estacdf2fe2023-07-18 10:59:06 +01001#!/bin/bash
2
3# ============LICENSE_START===============================================
4# Copyright (C) 2023 Nordix Foundation. All rights reserved.
5# ========================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17# ============LICENSE_END=================================================
18#
19
20echo "######### Installing ACM components #########"
21
22ENABLE_COMPONENTS=(policy-models-simulator policy-clamp-runtime-acm policy-clamp-ac-kserve-ppnt policy-clamp-ac-k8s-ppnt policy-clamp-ac-a1pms-ppnt)
23DISABLE_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)
24
25ACM_VALUES_FILE="docker/helm/policy/values.yaml"
26A1PMS_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-a1pms-ppnt/resources/config/A1pmsParticipantParameters.yaml"
27K8S_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-k8s-ppnt/values.yaml"
aravind.este1a83822023-09-06 13:46:58 +010028K8S_VERSIONS_FILE="docker/compose/get-k8s-versions.sh"
aravind.estacdf2fe2023-07-18 10:59:06 +010029
30IP_ADDRESS=$(hostname -I | awk '{print $1}')
31echo "IP Address : $IP_ADDRESS"
32
aravind.est44794c72023-08-25 15:32:59 +010033git clone "https://gerrit.onap.org/r/policy/docker"
aravind.estacdf2fe2023-07-18 10:59:06 +010034
35CWD=$(pwd)
36export WORKSPACE="$CWD/docker"
37
aravind.este1a83822023-09-06 13:46:58 +010038#Temporary workaround. Should be removed once this gets fixed in policy/docker repo
39echo "Update policy-db-migrator version..."
40yq eval '.dbmigrator.image="onap/policy-db-migrator:3.0-SNAPSHOT-latest"' -i $ACM_VALUES_FILE
41sed -i 's/component=policy-clamp-ac-kserve-ppnt/component=policy-clamp-ac-sim-ppnt/g' $K8S_VERSIONS_FILE
42PARAMETER_STRING="metrics:\n security:\n disabled: false"
43echo -e "$PARAMETER_STRING" >> docker/helm/policy/components/policy-clamp-runtime-acm/resources/config/acRuntimeParameters.yaml
44
aravind.estacdf2fe2023-07-18 10:59:06 +010045echo "Updating policy docker image versions..."
aravind.este1a83822023-09-06 13:46:58 +010046bash $K8S_VERSIONS_FILE
aravind.estacdf2fe2023-07-18 10:59:06 +010047
48echo "Enabling the access for the clusterroles..."
49kubectl apply -f resources/acm-role-binding.yaml
50
51for element in "${ENABLE_COMPONENTS[@]}"; do
52 echo "Enabling component $element"
53 yq eval ".$element.enabled"="true" -i $ACM_VALUES_FILE
54done
55
56for element in "${DISABLE_COMPONENTS[@]}"; do
57 echo "Disabling component $element"
58 yq eval ".$element.enabled"="false" -i $ACM_VALUES_FILE
59done
60
61echo "Updating A1PMS Participant"
62yq eval '.a1pms.baseUrl="http://policymanagementservice.nonrtric:9080"' -i $A1PMS_CONFIGURATION_FILE
63
64echo "Updating the k8s participant repo list"
65yq eval '.repoList.helm.repos += {"repoName":"local","address":"http://'$IP_ADDRESS':8879/charts"}' -i $K8S_CONFIGURATION_FILE
66
67echo "Building policy helm charts..."
68helm dependency build docker/helm/policy/
69
70echo "Installing policy helm charts..."
71helm install csit-policy docker/helm/policy/ -n default
72
73while [[ $TIME -lt 2000 ]]; do
74 NONRTRIC_PODS=$(kubectl get pods -n default --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers)
75 if [[ -z "$NONRTRIC_PODS" ]]; then
76 echo "All ACM Components are running."
77 kubectl get pods -n default
78 break
79 fi
80
81 echo "Waiting for ACM Components to be running..."
82 echo "These pods are not running"
83 echo "$NONRTRIC_PODS"
84 TIME=$(expr $TIME + 5)
85 sleep 5
86done
87
88echo "ACM Components Installation Completed."