blob: 76362e071495d6ba59e2e19615fa70302ade04b4 [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"
28
29IP_ADDRESS=$(hostname -I | awk '{print $1}')
30echo "IP Address : $IP_ADDRESS"
31
32git clone -b london "https://gerrit.onap.org/r/policy/docker"
33
34CWD=$(pwd)
35export WORKSPACE="$CWD/docker"
36
37echo "Updating policy docker image versions..."
38bash docker/compose/get-k8s-versions.sh
39
40echo "Enabling the access for the clusterroles..."
41kubectl apply -f resources/acm-role-binding.yaml
42
43for element in "${ENABLE_COMPONENTS[@]}"; do
44 echo "Enabling component $element"
45 yq eval ".$element.enabled"="true" -i $ACM_VALUES_FILE
46done
47
48for element in "${DISABLE_COMPONENTS[@]}"; do
49 echo "Disabling component $element"
50 yq eval ".$element.enabled"="false" -i $ACM_VALUES_FILE
51done
52
53echo "Updating A1PMS Participant"
54yq eval '.a1pms.baseUrl="http://policymanagementservice.nonrtric:9080"' -i $A1PMS_CONFIGURATION_FILE
55
56echo "Updating the k8s participant repo list"
57yq eval '.repoList.helm.repos += {"repoName":"local","address":"http://'$IP_ADDRESS':8879/charts"}' -i $K8S_CONFIGURATION_FILE
58
59echo "Building policy helm charts..."
60helm dependency build docker/helm/policy/
61
62echo "Installing policy helm charts..."
63helm install csit-policy docker/helm/policy/ -n default
64
65while [[ $TIME -lt 2000 ]]; do
66 NONRTRIC_PODS=$(kubectl get pods -n default --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers)
67 if [[ -z "$NONRTRIC_PODS" ]]; then
68 echo "All ACM Components are running."
69 kubectl get pods -n default
70 break
71 fi
72
73 echo "Waiting for ACM Components to be running..."
74 echo "These pods are not running"
75 echo "$NONRTRIC_PODS"
76 TIME=$(expr $TIME + 5)
77 sleep 5
78done
79
80echo "ACM Components Installation Completed."