NONRTRIC - PMS Fix dynamic configuration 45/7545/3
authorPatrikBuhr <patrik.buhr@est.tech>
Thu, 9 Dec 2021 13:16:01 +0000 (14:16 +0100)
committerPatrikBuhr <patrik.buhr@est.tech>
Wed, 12 Jan 2022 13:43:02 +0000 (14:43 +0100)
The problem was that the config cannot be updated via REST if the file is controlled by a configmap.
The configmap for PMS application can only be used for initial configuration after this change.

The file is moved from
/opt/app/policy-agent/data/application_configuration.json -> /var/policy-management-service/application_configuration.json

/var/policy-management-service/ is mapped to a persistent volume claim.

Config map which now is only initial (installation) data is mapped to:
/etc/app/policy-management-service/initialdata

An init container copies the initial configuration file /etc/app/policy-management-service/initialdata/application_configuration.json to /var/policy-management-service/
unless it is already there.

Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-689
Change-Id: I79be05bbc4d18ad1914efc3cbcdf932ede71718d

nonrtric/RECIPE_EXAMPLE/example_recipe.yaml
nonrtric/helm/nonrtric/templates/pv1.yaml
nonrtric/helm/nonrtric/templates/pv2.yaml
nonrtric/helm/nonrtric/values.yaml
nonrtric/helm/policymanagementservice/resources/config/application.yaml
nonrtric/helm/policymanagementservice/templates/statefulset.yaml

index 1a0edb1..c08789d 100644 (file)
@@ -36,14 +36,15 @@ nonrtric:
     # Set the size to 0 if you do not need the volume (if you are using Dynamic Volume Provisioning)
     size: 2Gi
     storageClassName: pms-storage
     # Set the size to 0 if you do not need the volume (if you are using Dynamic Volume Provisioning)
     size: 2Gi
     storageClassName: pms-storage
+    hostPath: /var/nonrtric/pms-storage
   volume2:
      # Set the size to 0 if you do not need the volume (if you are using Dynamic Volume Provisioning)
     size: 2Gi
     storageClassName: ics-storage
   volume2:
      # Set the size to 0 if you do not need the volume (if you are using Dynamic Volume Provisioning)
     size: 2Gi
     storageClassName: ics-storage
+    hostPath: /var/nonrtric/ics-storage
   volume3:
     size: 1Gi
     storageClassName: helmmanager-storage
   volume3:
     size: 1Gi
     storageClassName: helmmanager-storage
-
 common:
   releasePrefix: r3-dev-nonrtric
 # Do not change the namespace
 common:
   releasePrefix: r3-dev-nonrtric
 # Do not change the namespace
index c9ba128..27426e4 100644 (file)
@@ -29,7 +29,7 @@ spec:
     - ReadWriteMany
   persistentVolumeReclaimPolicy: Retain
   hostPath:
     - ReadWriteMany
   persistentVolumeReclaimPolicy: Retain
   hostPath:
-    path: /dockerdata-nfs/nonrtric/volume1
+    path:  {{ .Values.nonrtric.volume1.hostPath }}
   storageClassName: {{ .Values.nonrtric.volume1.storageClassName }}
 
 {{- end }}
   storageClassName: {{ .Values.nonrtric.volume1.storageClassName }}
 
 {{- end }}
index 6fd313c..0058780 100644 (file)
@@ -29,7 +29,7 @@ spec:
     - ReadWriteMany
   persistentVolumeReclaimPolicy: Retain
   hostPath:
     - ReadWriteMany
   persistentVolumeReclaimPolicy: Retain
   hostPath:
-    path: /dockerdata-nfs/nonrtric/volume2
+    path:  {{ .Values.nonrtric.volume2.hostPath }}
   storageClassName: {{ .Values.nonrtric.volume2.storageClassName }}
 
 {{- end }}
   storageClassName: {{ .Values.nonrtric.volume2.storageClassName }}
 
 {{- end }}
index 4b07fb9..bda8098 100644 (file)
@@ -28,9 +28,11 @@ nonrtric:
   volume1:
     size: 1Gi
     storageClassName: volume1
   volume1:
     size: 1Gi
     storageClassName: volume1
+    hostPath: /dockerdata-nfs/nonrtric/volume1
   volume2:
     size: 1Gi
     storageClassName: volume2
   volume2:
     size: 1Gi
     storageClassName: volume2
+    hostPath: /dockerdata-nfs/nonrtric/volume2
   volume3:
     size: 1Gi
     storageClassName: volume3
\ No newline at end of file
   volume3:
     size: 1Gi
     storageClassName: volume3
\ No newline at end of file
index 5fc5051..558216b 100644 (file)
@@ -53,7 +53,7 @@ server:
 app:
   # Location of the component configuration file. The file will only be used if the Consul database is not used;
   # configuration from the Consul will override the file.
 app:
   # Location of the component configuration file. The file will only be used if the Consul database is not used;
   # configuration from the Consul will override the file.
-  filepath: /opt/app/policy-agent/data/application_configuration.json
+  filepath: /var/policy-management-service/application_configuration.json
   webclient:
     # Configuration of the trust store used for the HTTP client (outgoing requests)
     # The file location and the password for the truststore is only relevant if trust-store-used == true
   webclient:
     # Configuration of the trust store used for the HTTP client (outgoing requests)
     # The file location and the password for the truststore is only relevant if trust-store-used == true
index 3ef2826..0930d07 100644 (file)
@@ -41,6 +41,21 @@ spec:
         release: {{ .Release.Name }}
     spec:
       hostname: {{ include "common.name.policymanagementservice" . }}
         release: {{ .Release.Name }}
     spec:
       hostname: {{ include "common.name.policymanagementservice" . }}
+      initContainers:
+      - name: copy
+        image: busybox:1.28
+        command:
+        - /bin/sh
+        - -c
+        - FILE=/var/policy-management-service/application_configuration.json;
+          if [ ! -f $FILE ]; then
+            cp  /etc/app/policy-management-service/initialdata/application_configuration.json $FILE;
+          fi
+        volumeMounts:
+        - name: {{ include "common.name.policymanagementservice" . }}-vardata
+          mountPath: "/var/policy-management-service"
+        - name: {{ include "common.name.policymanagementservice" . }}-policy-data
+          mountPath: /etc/app/policy-management-service/initialdata
       containers:
       - name: {{ include "common.container.policymanagementservice" . }}
         image: {{ .Values.policymanagementservice.image.registry }}/{{ .Values.policymanagementservice.image.name }}:{{ .Values.policymanagementservice.image.tag }}
       containers:
       - name: {{ include "common.container.policymanagementservice" . }}
         image: {{ .Values.policymanagementservice.image.registry }}/{{ .Values.policymanagementservice.image.name }}:{{ .Values.policymanagementservice.image.tag }}
@@ -67,7 +82,7 @@ spec:
         - name: {{ include "common.name.policymanagementservice" . }}-policy-config
           mountPath: /opt/app/policy-agent/config
         - name: {{ include "common.name.policymanagementservice" . }}-policy-data
         - 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: /etc/app/policy-management-service/initialdata
       volumes:
         - name: {{ include "common.name.policymanagementservice" . }}-policy-config
           configMap:
       volumes:
         - name: {{ include "common.name.policymanagementservice" . }}-policy-config
           configMap: