From: PatrikBuhr Date: Mon, 12 Apr 2021 15:02:21 +0000 (+0200) Subject: NONRTRIC - PMS Persistent storage of policies and type definitions X-Git-Tag: f-release~55 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fdep.git;a=commitdiff_plain;h=866a34f4a876d61246b67ee6fc9ec066c7960ad2 NONRTRIC - PMS Persistent storage of policies and type definitions Policy types and type definitions are stored persistently to survive a restart of PMS. Some fixes in the install script Change-Id: Id636498baa7bdc7e86cc9ac5b76c4c565f17fc04 Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-478 --- diff --git a/bin/deploy-nonrtric b/bin/deploy-nonrtric index dbaaea39..887c04ee 100755 --- a/bin/deploy-nonrtric +++ b/bin/deploy-nonrtric @@ -17,6 +17,8 @@ # This script deploys NonRtRic components automatically + + if [ "$#" -eq 1 ]; then OVERRIDEYAML=$1 else @@ -27,7 +29,7 @@ else -f) OVERRIDEYAML=$2 shift - ;; + ;; *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c esac @@ -50,6 +52,10 @@ fi ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +echo "** $ROOT_DIR" +rm $ROOT_DIR/../nonrtric/helm/*/charts/*.tgz + + #Check for helm3 IS_HELM3=$(helm version -c --short|grep -e "^v3") @@ -83,10 +89,6 @@ if [ -z "$HELM_REPO_PID" ]; then fi -$ROOT_DIR/prepare-common-templates - -COMPONENTS=${LIST_OF_COMPONENTS:-"controlpanel a1controller a1simulator policymanagementservice enrichmentservice rappcatalogueservice nonrtricgateway"} -echo "Packaging NONRTRIC components [$COMPONENTS]" # Package common templates and serve it using Helm local repo HELM_LOCAL_REPO="" if [ $IS_HELM3 ] @@ -98,19 +100,29 @@ else HELM_LOCAL_REPO="${HELM_HOME}/repository/local/" fi + +rm $HELM_LOCAL_REPO/* + +helm repo remove local +$ROOT_DIR/prepare-common-templates + +COMPONENTS="controlpanel a1controller a1simulator policymanagementservice enrichmentservice rappcatalogueservice nonrtricgateway" for component in $COMPONENTS; do + echo "Packaging NONRTRIC component [$component]" helm dep up $ROOT_DIR/../nonrtric/helm/$component VERSION=$(cat $ROOT_DIR/../nonrtric/helm/$component/Chart.yaml | grep version | awk '{print $2}') helm package -d /tmp $ROOT_DIR/../nonrtric/helm/$component cp /tmp/$component-$VERSION.tgz ${HELM_LOCAL_REPO} done +helm dep up $ROOT_DIR/../nonrtric/helm/nonrtric + helm repo index ${HELM_LOCAL_REPO} # Make sure that helm local repo is added -helm repo remove local -helm repo add local http://127.0.0.1:8879/charts +helm repo add local http://127.0.0.1:8879/charts --force-update echo "Finished Packaging NONRTRIC components [$COMPONENTS]" + $ROOT_DIR/../nonrtric/bin/install -f $OVERRIDEYAML diff --git a/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml b/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml index c1b718f4..7efd8e1c 100644 --- a/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml +++ b/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml @@ -23,7 +23,7 @@ common: # Change the namespaces using the following options namespace: nonrtric: nonrtric - +# any nonrtric chart can be installed: nonrtric (all components), controlpanel, a1controller, a1simulator, policymanagementservice, enrichmentservice, rappcatalogueservice, nonrtricgateway component: nonrtric # A1 Conttroller may take few more minutes to start. Increase the initialDelaySeconds in liveness to avoid container restart. @@ -129,6 +129,12 @@ policymanagementservice: readiness: initialDelaySeconds: 20 periodSeconds: 10 + persistence: + volumeReclaimPolicy: Retain + accessMode: ReadWriteOnce + size: 2Gi + mountPath: /dockerdata-nfs + mountSubPath: nonrtric/policymanagementservice enrichmentservice: enrichmentservice: @@ -198,4 +204,4 @@ nonrtricgateway: periodSeconds: 10 readiness: initialDelaySeconds: 20 - periodSeconds: 10 \ No newline at end of file + periodSeconds: 10 diff --git a/nonrtric/bin/install b/nonrtric/bin/install index 608556df..8b14da0b 100755 --- a/nonrtric/bin/install +++ b/nonrtric/bin/install @@ -22,10 +22,7 @@ while [ -n "$1" ]; do # while loop starts -f) OVERRIDEYAML=$2 shift - ;; - -c) LIST_OF_COMPONENTS=$2 - shift - ;; + ;; *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c esac @@ -52,7 +49,6 @@ NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}') RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}') PARENT_CHART=$(cat $OVERRIDEYAML | awk '/^ *component:/{print $2}') -COMPONENTS=${LIST_OF_COMPONENTS:-"controlpanel a1controller a1simulator policymanagementservice enrichmentservice nonrtric rappcatalogueservice nonrtricgateway"} echo "Chart name- $PARENT_CHART" if ! kubectl get ns ${NONRTRIC_NAMESPACE:-nonrtric}> /dev/null 2>&1; then @@ -64,15 +60,13 @@ fi kubectl create configmap -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe --from-file=recipe=$OVERRIDEYAML -echo "Deploying NONRTRIC components [$COMPONENTS]" - -echo "Updating the Parent Chart [$PARENT_CHART]" -helm dep up $DIR/../helm/$PARENT_CHART +echo "Deploying NONRTRIC [$PARENT_CHART]" HELM_NAME_OPT="" if [ -z $IS_HELM3 ];then HELM_NAME_OPT="--name" fi +echo "helm install -f $OVERRIDEYAML --namespace ${NONRTRIC_NAMESPACE:-nonrtric} ${HELM_NAME_OPT} ${RELEASE_PREFIX} $DIR/../helm/${PARENT_CHART}" helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" ${HELM_NAME_OPT} "${RELEASE_PREFIX}" $DIR/../helm/"${PARENT_CHART}" diff --git a/nonrtric/helm/policymanagementservice/resources/config/application.yaml b/nonrtric/helm/policymanagementservice/resources/config/application.yaml index dae3fcea..a5faac5d 100644 --- a/nonrtric/helm/policymanagementservice/resources/config/application.yaml +++ b/nonrtric/helm/policymanagementservice/resources/config/application.yaml @@ -64,3 +64,5 @@ app: # The HTTP proxy (if configured) will only be used for accessing NearRT RIC:s http.proxy-host: http.proxy-port: 0 + # path where the service can store data + vardata-directory: /var/policy-management-service diff --git a/nonrtric/helm/policymanagementservice/templates/deployment.yaml b/nonrtric/helm/policymanagementservice/templates/deployment.yaml index 68a39a12..939f9351 100644 --- a/nonrtric/helm/policymanagementservice/templates/deployment.yaml +++ b/nonrtric/helm/policymanagementservice/templates/deployment.yaml @@ -61,14 +61,19 @@ spec: initialDelaySeconds: {{ .Values.policymanagementservice.liveness.initialDelaySeconds }} periodSeconds: {{ .Values.policymanagementservice.liveness.periodSeconds }} volumeMounts: + - name: {{ include "common.name.policymanagementservice" . }}-vardata + mountPath: "/var/policy-management-service/database" - name: {{ include "common.name.policymanagementservice" . }}-policy-config mountPath: /opt/app/policy-agent/config - name: {{ include "common.name.policymanagementservice" . }}-policy-data - mountPath: /opt/app/policy-agent/data + mountPath: /opt/app/policy-agent/data volumes: - name: {{ include "common.name.policymanagementservice" . }}-policy-config configMap: name: {{ include "common.name.policymanagementservice" . }}-configmap-config - name: {{ include "common.name.policymanagementservice" . }}-policy-data configMap: - name: {{ include "common.name.policymanagementservice" . }}-configmap-data \ No newline at end of file + name: {{ include "common.name.policymanagementservice" . }}-configmap-data + - name: {{ include "common.name.policymanagementservice" . }}-vardata + persistentVolumeClaim: + claimName: {{ include "common.name.policymanagementservice" . }}-vardata-pvc diff --git a/nonrtric/helm/policymanagementservice/templates/pv.yaml b/nonrtric/helm/policymanagementservice/templates/pv.yaml new file mode 100644 index 00000000..f840a788 --- /dev/null +++ b/nonrtric/helm/policymanagementservice/templates/pv.yaml @@ -0,0 +1,38 @@ +################################################################################ +# Copyright (c) 2020 Nordix Foundation. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + + +kind: PersistentVolume +apiVersion: v1 +metadata: + name: {{ include "common.name.policymanagementservice" . }} + namespace: {{ include "common.namespace.nonrtric" . }} + labels: + app: {{ include "common.namespace.nonrtric" . }}-{{ include "common.name.policymanagementservice" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + name: {{ include "common.name.policymanagementservice" . }} +spec: + capacity: + storage: {{ .Values.policymanagementservice.persistence.size}} + accessModes: + - {{ .Values.policymanagementservice.persistence.accessMode }} + persistentVolumeReclaimPolicy: {{ .Values.policymanagementservice.persistence.volumeReclaimPolicy }} + hostPath: + path: {{ .Values.policymanagementservice.persistence.mountPath }}/{{ .Values.policymanagementservice.persistence.mountSubPath }} + storageClassName: "{{ .Values.policymanagementservice.persistence.storageClass }}" + diff --git a/nonrtric/helm/policymanagementservice/templates/pvc.yaml b/nonrtric/helm/policymanagementservice/templates/pvc.yaml new file mode 100644 index 00000000..1c84e7bd --- /dev/null +++ b/nonrtric/helm/policymanagementservice/templates/pvc.yaml @@ -0,0 +1,35 @@ +################################################################################ +# Copyright (c) 2021 Nordix Foundation. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + + +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "common.name.policymanagementservice" . }}-vardata-pvc + namespace: {{ include "common.namespace.nonrtric" . }} + labels: + app: {{ include "common.namespace.nonrtric" . }}-{{ include "common.name.policymanagementservice" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "{{ .Values.policymanagementservice.persistence.size }}" + storageClassName: "{{ .Values.policymanagementservice.persistence.storageClass }}" + diff --git a/nonrtric/helm/policymanagementservice/values.yaml b/nonrtric/helm/policymanagementservice/values.yaml index f10aabdb..3e67451a 100644 --- a/nonrtric/helm/policymanagementservice/values.yaml +++ b/nonrtric/helm/policymanagementservice/values.yaml @@ -37,4 +37,13 @@ policymanagementservice: periodSeconds: 10 readiness: initialDelaySeconds: 20 - periodSeconds: 10 \ No newline at end of file + periodSeconds: 10 + persistence: + volumeReclaimPolicy: Retain + accessMode: ReadWriteOnce + size: 2Gi + mountPath: /dockerdata-nfs + mountSubPath: nonrtric/policymanagementservice + storageClass: "manual" + enabled: true + #existingClaim: