NONRTRIC - PMS Persistent storage of policies and type definitions 79/5879/11
authorPatrikBuhr <patrik.buhr@est.tech>
Mon, 12 Apr 2021 15:02:21 +0000 (17:02 +0200)
committerZhe Huang <zhehuang@research.att.com>
Thu, 29 Apr 2021 18:25:46 +0000 (18:25 +0000)
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 <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-478

bin/deploy-nonrtric
nonrtric/RECIPE_EXAMPLE/example_recipe.yaml
nonrtric/bin/install
nonrtric/helm/policymanagementservice/resources/config/application.yaml
nonrtric/helm/policymanagementservice/templates/deployment.yaml
nonrtric/helm/policymanagementservice/templates/pv.yaml [new file with mode: 0644]
nonrtric/helm/policymanagementservice/templates/pvc.yaml [new file with mode: 0644]
nonrtric/helm/policymanagementservice/values.yaml

index dbaaea3..887c04e 100755 (executable)
@@ -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
index c1b718f..7efd8e1 100644 (file)
@@ -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
index 608556d..8b14da0 100755 (executable)
@@ -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}"
 
index dae3fce..a5faac5 100644 (file)
@@ -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
index 68a39a1..939f935 100644 (file)
@@ -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 (file)
index 0000000..f840a78
--- /dev/null
@@ -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 (file)
index 0000000..1c84e7b
--- /dev/null
@@ -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 }}"
+
index f10aabd..3e67451 100644 (file)
@@ -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: