aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # ============LICENSE_START=============================================== |
| 4 | # Copyright (C) 2023 Nordix Foundation. All rights reserved. |
aravind.est | 06058ee | 2023-11-24 09:59:04 +0000 | [diff] [blame] | 5 | # Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 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 |
| 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 | |
| 21 | echo "######### Installing ACM components #########" |
| 22 | |
| 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) |
| 25 | |
| 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" |
aravind.est | e1a8382 | 2023-09-06 13:46:58 +0100 | [diff] [blame] | 29 | K8S_VERSIONS_FILE="docker/compose/get-k8s-versions.sh" |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 30 | |
| 31 | IP_ADDRESS=$(hostname -I | awk '{print $1}') |
| 32 | echo "IP Address : $IP_ADDRESS" |
| 33 | |
aravind.est | 06058ee | 2023-11-24 09:59:04 +0000 | [diff] [blame] | 34 | A1PMS_HOST=${A1PMS_HOST:-http://policymanagementservice.nonrtric:9080} |
| 35 | CHART_REPO_HOST=${CHART_REPO_HOST:-'http://'$IP_ADDRESS':8879/charts'} |
| 36 | |
aravind.est | 44794c7 | 2023-08-25 15:32:59 +0100 | [diff] [blame] | 37 | git clone "https://gerrit.onap.org/r/policy/docker" |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 38 | |
| 39 | CWD=$(pwd) |
| 40 | export WORKSPACE="$CWD/docker" |
| 41 | |
aravind.est | e1a8382 | 2023-09-06 13:46:58 +0100 | [diff] [blame] | 42 | #Temporary workaround. Should be removed once this gets fixed in policy/docker repo |
| 43 | echo "Update policy-db-migrator version..." |
| 44 | yq eval '.dbmigrator.image="onap/policy-db-migrator:3.0-SNAPSHOT-latest"' -i $ACM_VALUES_FILE |
aravind.est | e1a8382 | 2023-09-06 13:46:58 +0100 | [diff] [blame] | 45 | |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 46 | echo "Updating policy docker image versions..." |
aravind.est | e1a8382 | 2023-09-06 13:46:58 +0100 | [diff] [blame] | 47 | bash $K8S_VERSIONS_FILE |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 48 | |
| 49 | echo "Enabling the access for the clusterroles..." |
| 50 | kubectl apply -f resources/acm-role-binding.yaml |
| 51 | |
| 52 | for element in "${ENABLE_COMPONENTS[@]}"; do |
| 53 | echo "Enabling component $element" |
| 54 | yq eval ".$element.enabled"="true" -i $ACM_VALUES_FILE |
| 55 | done |
| 56 | |
| 57 | for element in "${DISABLE_COMPONENTS[@]}"; do |
| 58 | echo "Disabling component $element" |
| 59 | yq eval ".$element.enabled"="false" -i $ACM_VALUES_FILE |
| 60 | done |
| 61 | |
| 62 | echo "Updating A1PMS Participant" |
aravind.est | 06058ee | 2023-11-24 09:59:04 +0000 | [diff] [blame] | 63 | yq eval '.a1pms.baseUrl="'$A1PMS_HOST'"' -i $A1PMS_CONFIGURATION_FILE |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 64 | |
| 65 | echo "Updating the k8s participant repo list" |
aravind.est | 06058ee | 2023-11-24 09:59:04 +0000 | [diff] [blame] | 66 | yq eval '.repoList.helm.repos += {"repoName":"local","address":"'$CHART_REPO_HOST'"}' -i $K8S_CONFIGURATION_FILE |
aravind.est | acdf2fe | 2023-07-18 10:59:06 +0100 | [diff] [blame] | 67 | |
| 68 | echo "Building policy helm charts..." |
| 69 | helm dependency build docker/helm/policy/ |
| 70 | |
| 71 | echo "Installing policy helm charts..." |
| 72 | helm install csit-policy docker/helm/policy/ -n default |
| 73 | |
| 74 | while [[ $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 |
| 87 | done |
| 88 | |
aravind.est | 06058ee | 2023-11-24 09:59:04 +0000 | [diff] [blame] | 89 | echo "ACM Components Installation Completed." |