blob: 41cf3013424d9cd955f2b59ff340b9cd82d608b2 [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.
aravind.est06058ee2023-11-24 09:59:04 +00005# Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved.
aravind.estacdf2fe2023-07-18 10:59:06 +01006# ========================================================================
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
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
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=================================================
19#
20
21echo "######### Installing ACM components #########"
22
23ENABLE_COMPONENTS=(policy-models-simulator policy-clamp-runtime-acm policy-clamp-ac-kserve-ppnt policy-clamp-ac-k8s-ppnt policy-clamp-ac-a1pms-ppnt)
24DISABLE_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)
25
26ACM_VALUES_FILE="docker/helm/policy/values.yaml"
27A1PMS_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-a1pms-ppnt/resources/config/A1pmsParticipantParameters.yaml"
28K8S_CONFIGURATION_FILE="docker/helm/policy/components/policy-clamp-ac-k8s-ppnt/values.yaml"
aravind.este1a83822023-09-06 13:46:58 +010029K8S_VERSIONS_FILE="docker/compose/get-k8s-versions.sh"
aravind.estacdf2fe2023-07-18 10:59:06 +010030
31IP_ADDRESS=$(hostname -I | awk '{print $1}')
32echo "IP Address : $IP_ADDRESS"
33
aravind.est06058ee2023-11-24 09:59:04 +000034A1PMS_HOST=${A1PMS_HOST:-http://policymanagementservice.nonrtric:9080}
35CHART_REPO_HOST=${CHART_REPO_HOST:-'http://'$IP_ADDRESS':8879/charts'}
36
aravind.est44794c72023-08-25 15:32:59 +010037git clone "https://gerrit.onap.org/r/policy/docker"
aravind.estacdf2fe2023-07-18 10:59:06 +010038
39CWD=$(pwd)
40export WORKSPACE="$CWD/docker"
41
aravind.este1a83822023-09-06 13:46:58 +010042#Temporary workaround. Should be removed once this gets fixed in policy/docker repo
43echo "Update policy-db-migrator version..."
44yq eval '.dbmigrator.image="onap/policy-db-migrator:3.0-SNAPSHOT-latest"' -i $ACM_VALUES_FILE
aravind.este1a83822023-09-06 13:46:58 +010045
aravind.estacdf2fe2023-07-18 10:59:06 +010046echo "Updating policy docker image versions..."
aravind.este1a83822023-09-06 13:46:58 +010047bash $K8S_VERSIONS_FILE
aravind.estacdf2fe2023-07-18 10:59:06 +010048
49echo "Enabling the access for the clusterroles..."
50kubectl apply -f resources/acm-role-binding.yaml
51
52for element in "${ENABLE_COMPONENTS[@]}"; do
53 echo "Enabling component $element"
54 yq eval ".$element.enabled"="true" -i $ACM_VALUES_FILE
55done
56
57for element in "${DISABLE_COMPONENTS[@]}"; do
58 echo "Disabling component $element"
59 yq eval ".$element.enabled"="false" -i $ACM_VALUES_FILE
60done
61
62echo "Updating A1PMS Participant"
aravind.est06058ee2023-11-24 09:59:04 +000063yq eval '.a1pms.baseUrl="'$A1PMS_HOST'"' -i $A1PMS_CONFIGURATION_FILE
aravind.estacdf2fe2023-07-18 10:59:06 +010064
65echo "Updating the k8s participant repo list"
aravind.est06058ee2023-11-24 09:59:04 +000066yq eval '.repoList.helm.repos += {"repoName":"local","address":"'$CHART_REPO_HOST'"}' -i $K8S_CONFIGURATION_FILE
aravind.estacdf2fe2023-07-18 10:59:06 +010067
68echo "Building policy helm charts..."
69helm dependency build docker/helm/policy/
70
71echo "Installing policy helm charts..."
72helm install csit-policy docker/helm/policy/ -n default
73
74while [[ $TIME -lt 2000 ]]; do
75 NONRTRIC_PODS=$(kubectl get pods -n default --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers)
76 if [[ -z "$NONRTRIC_PODS" ]]; then
77 echo "All ACM Components are running."
78 kubectl get pods -n default
79 break
80 fi
81
82 echo "Waiting for ACM Components to be running..."
83 echo "These pods are not running"
84 echo "$NONRTRIC_PODS"
85 TIME=$(expr $TIME + 5)
86 sleep 5
87done
88
aravind.est06058ee2023-11-24 09:59:04 +000089echo "ACM Components Installation Completed."