AETHER-1361 Fix restart fails when mounted configmap with subpath modified

Also removed unnecessary environment variables for gx-app container

Change-Id: I10c87fa4e7c0795a7c2f788cce6e81f212b78a76
diff --git a/omec/omec-control-plane/Chart.yaml b/omec/omec-control-plane/Chart.yaml
index a10754b..9bc06d3 100644
--- a/omec/omec-control-plane/Chart.yaml
+++ b/omec/omec-control-plane/Chart.yaml
@@ -10,4 +10,4 @@
 name: omec-control-plane
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.6.7
+version: 0.6.8
diff --git a/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
index 1528dc2..b7f6cb0 100644
--- a/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
@@ -9,7 +9,7 @@
 
 mkdir -p /opt/cp/config
 cd /opt/cp/config
-cp /etc/cp/config/{*.cfg,*.json,*.conf,*.sh} .
+cp /etc/cp/config/{*.cfg,*.json,*.conf} .
 
 case $APPLICATION in
     "ngic_controlplane")
@@ -46,6 +46,3 @@
       echo "invalid app $APPLICATION"
       ;;
 esac
-    
-
-
diff --git a/omec/omec-control-plane/templates/configmap-hss.yaml b/omec/omec-control-plane/templates/configmap-hss.yaml
index 098827c..8d94491 100644
--- a/omec/omec-control-plane/templates/configmap-hss.yaml
+++ b/omec/omec-control-plane/templates/configmap-hss.yaml
@@ -30,7 +30,7 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: hss
+  name: hss-configs
   labels:
 {{ tuple "hss" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 data:
@@ -96,12 +96,20 @@
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6as6d.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6t.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6c.fdx";
-  hss-run.sh: |
-{{ tuple "bin/_hss-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
-  hss-bootstrap.sh: |
-{{ tuple "bin/_hss-bootstrap.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- range $key, $value := .Values.config.hss.cfgFiles }}
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: hss-scripts
+  labels:
+{{ tuple "hss" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+  hss-run.sh: |
+{{ tuple "bin/_hss-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+  hss-bootstrap.sh: |
+{{ tuple "bin/_hss-bootstrap.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-mme.yaml b/omec/omec-control-plane/templates/configmap-mme.yaml
index 57624c7..efbf281 100644
--- a/omec/omec-control-plane/templates/configmap-mme.yaml
+++ b/omec/omec-control-plane/templates/configmap-mme.yaml
@@ -20,7 +20,7 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: mme
+  name: mme-configs
   labels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 data:
@@ -81,12 +81,20 @@
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6t.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_SGd.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_T6aT6bT7.fdx";
-  mme-init.sh: |
-{{ tuple "bin/_mme-init.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
-  mme-run.sh: |
-{{ tuple "bin/_mme-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- range $key, $value := .Values.config.mme.cfgFiles }}
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: mme-scripts
+  labels:
+{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+  mme-init.sh: |
+{{ tuple "bin/_mme-init.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+  mme-run.sh: |
+{{ tuple "bin/_mme-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-pcrf.yaml b/omec/omec-control-plane/templates/configmap-pcrf.yaml
index e4177a1..9400601 100644
--- a/omec/omec-control-plane/templates/configmap-pcrf.yaml
+++ b/omec/omec-control-plane/templates/configmap-pcrf.yaml
@@ -27,7 +27,7 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: pcrf
+  name: pcrf-configs
   labels:
 {{ tuple "pcrf" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 data:
@@ -96,12 +96,20 @@
     LoadExtension = "/usr/local/lib/freeDiameter/dict_Rx.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_Sd.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_St.fdx";
-  pcrf-run.sh: |
-{{ tuple "bin/_pcrf-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
-  pcrf-bootstrap.sh: |
-{{ tuple "bin/_pcrf-bootstrap.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- range $key, $value := .Values.config.pcrf.cfgFiles }}
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: pcrf-scripts
+  labels:
+{{ tuple "pcrf" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+  pcrf-run.sh: |
+{{ tuple "bin/_pcrf-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+  pcrf-bootstrap.sh: |
+{{ tuple "bin/_pcrf-bootstrap.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-spgwc.yaml b/omec/omec-control-plane/templates/configmap-spgwc.yaml
index e771923..ab73c62 100644
--- a/omec/omec-control-plane/templates/configmap-spgwc.yaml
+++ b/omec/omec-control-plane/templates/configmap-spgwc.yaml
@@ -33,7 +33,7 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: spgwc
+  name: spgwc-configs
   labels:
 {{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 data:
@@ -76,7 +76,6 @@
     [STATIC_IP_POOL_CONFIG]
     IP_POOL_IP= {{.Values.config.spgwc.staticUeIpPool.ip }}
     IP_POOL_MASK= {{ .Values.config.spgwc.staticUeIpPool.mask }}
-
   gx.conf: |
     Identity = {{ tuple "spgwc" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }};
     Realm = {{ tuple "spgwc" "realm" . | include "omec-control-plane.diameter_endpoint" | quote }};
@@ -131,10 +130,18 @@
     LoadExtension = "/usr/local/lib/freeDiameter/dict_ts32299_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_CreditControl.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_Gx.fdx";
-  spgwc-run.sh: |
-{{ tuple "bin/_spgwc-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- range $key, $value := .Values.config.spgwc.jsonCfgFiles }}
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: spgwc-scripts
+  labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+  spgwc-run.sh: |
+{{ tuple "bin/_spgwc-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/statefulset-hss.yaml b/omec/omec-control-plane/templates/statefulset-hss.yaml
index 7c4c4a6..11ce47c 100644
--- a/omec/omec-control-plane/templates/statefulset-hss.yaml
+++ b/omec/omec-control-plane/templates/statefulset-hss.yaml
@@ -45,11 +45,10 @@
       - name: hss-bootstrap
         image: {{ .Values.images.tags.hssdb }}
         imagePullPolicy: {{ .Values.images.pullPolicy }}
-        command: ["/opt/c3po/hss/hss-bootstrap.sh"]
+        command: ["/opt/c3po/hss/scripts/hss-bootstrap.sh"]
         volumeMounts:
-        - name: hss-script
-          mountPath: /opt/c3po/hss/hss-bootstrap.sh
-          subPath: hss-bootstrap.sh
+        - name: scripts
+          mountPath: /opt/c3po/hss/scripts
     {{- if .Values.config.coreDump.enabled }}
 {{ tuple "hss" . | include "omec-control-plane.coredump_init" | indent 6 }}
     {{- end }}
@@ -64,29 +63,28 @@
       {{- end }}
         stdin: true
         tty: true
-        command: ["bash", "-c", "/opt/c3po/hss/hss-run.sh; sleep 3600"]
+        command: ["bash", "-c", "/opt/c3po/hss/scripts/hss-run.sh; sleep 3600"]
       {{- if .Values.resources.enabled }}
         resources:
 {{ toYaml .Values.resources.hss | indent 10 }}
       {{- end }}
         volumeMounts:
-        - name: hss-script
-          mountPath: /opt/c3po/hss/hss-run.sh
-          subPath: hss-run.sh
-        - name: hss-config
+        - name: scripts
+          mountPath: /opt/c3po/hss/scripts
+        - name: configs
           mountPath: /etc/hss/conf
       {{- if .Values.config.coreDump.enabled }}
         - name: coredump
           mountPath: /tmp/coredump
       {{- end }}
       volumes:
-      - name: hss-script
+      - name: scripts
         configMap:
-          name: hss
+          name: hss-scripts
           defaultMode: 493
-      - name: hss-config
+      - name: configs
         configMap:
-          name: hss
+          name: hss-configs
           defaultMode: 420
     {{- if .Values.config.coreDump.enabled }}
       - name: host-rootfs
diff --git a/omec/omec-control-plane/templates/statefulset-mme.yaml b/omec/omec-control-plane/templates/statefulset-mme.yaml
index c0c180c..c0b6e82 100644
--- a/omec/omec-control-plane/templates/statefulset-mme.yaml
+++ b/omec/omec-control-plane/templates/statefulset-mme.yaml
@@ -96,8 +96,7 @@
               fieldPath: status.podIP
         volumeMounts:
         - name: scripts
-          mountPath: /opt/mme/scripts/mme-init.sh
-          subPath: mme-init.sh
+          mountPath: /opt/mme/scripts
         - name: configs
           mountPath: /opt/mme/config
         - name: shared-data
@@ -130,8 +129,7 @@
           value: "container"
         volumeMounts:
         - name: scripts
-          mountPath: /opt/mme/scripts/mme-run.sh
-          subPath: mme-run.sh
+          mountPath: /opt/mme/scripts
         - name: shared-data
           mountPath: /opt/mme/config/shared
         - name: shared-app
@@ -162,8 +160,7 @@
           value: "container"
         volumeMounts:
         - name: scripts
-          mountPath: /opt/mme/scripts/mme-run.sh
-          subPath: mme-run.sh
+          mountPath: /opt/mme/scripts
         - name: shared-data
           mountPath: /opt/mme/config/shared
         - name: shared-app
@@ -194,8 +191,7 @@
           value: "container"
         volumeMounts:
         - name: scripts
-          mountPath: /opt/mme/scripts/mme-run.sh
-          subPath: mme-run.sh
+          mountPath: /opt/mme/scripts
         - name: shared-data
           mountPath: /opt/mme/config/shared
         - name: shared-app
@@ -224,8 +220,7 @@
           value: "container"
         volumeMounts:
         - name: scripts
-          mountPath: /opt/mme/scripts/mme-run.sh
-          subPath: mme-run.sh
+          mountPath: /opt/mme/scripts
         - name: shared-data
           mountPath: /opt/mme/config/shared
         - name: shared-app
@@ -237,11 +232,11 @@
       volumes:
       - name: scripts
         configMap:
-          name: mme
+          name: mme-scripts
           defaultMode: 493
       - name: configs
         configMap:
-          name: mme
+          name: mme-configs
           defaultMode: 420
       - name: shared-data
         emptyDir: {}
diff --git a/omec/omec-control-plane/templates/statefulset-pcrf.yaml b/omec/omec-control-plane/templates/statefulset-pcrf.yaml
index fe6c73e..45af96b 100644
--- a/omec/omec-control-plane/templates/statefulset-pcrf.yaml
+++ b/omec/omec-control-plane/templates/statefulset-pcrf.yaml
@@ -43,9 +43,8 @@
         imagePullPolicy: {{ .Values.images.pullPolicy }}
         command: ["/opt/c3po/pcrf/pcrf-bootstrap.sh"]
         volumeMounts:
-        - name: pcrf-script
-          mountPath: /opt/c3po/pcrf/pcrf-bootstrap.sh
-          subPath: pcrf-bootstrap.sh
+        - name: scripts
+          mountPath: /opt/c3po/pcrf
     {{- if .Values.config.coreDump.enabled }}
 {{ tuple "pcrf" . | include "omec-control-plane.coredump_init" | indent 6 }}
     {{- end }}
@@ -60,29 +59,28 @@
       {{- end }}
         stdin: true
         tty: true
-        command: ["bash", "-c", "/opt/c3po/pcrf/pcrf-run.sh"]
+        command: ["bash", "-c", "/opt/c3po/pcrf/scripts/pcrf-run.sh"]
       {{- if .Values.resources.enabled }}
         resources:
 {{ toYaml .Values.resources.pcrf | indent 10 }}
       {{- end }}
         volumeMounts:
-        - name: pcrf-script
-          mountPath: /opt/c3po/pcrf/pcrf-run.sh
-          subPath: pcrf-run.sh
-        - name: pcrf-config
+        - name: scripts
+          mountPath: /opt/c3po/pcrf/scripts
+        - name: configs
           mountPath: /etc/pcrf/conf
       {{- if .Values.config.coreDump.enabled }}
         - name: coredump
           mountPath: /tmp/coredump
       {{- end }}
       volumes:
-      - name: pcrf-script
+      - name: scripts
         configMap:
-          name: pcrf
+          name: pcrf-scripts
           defaultMode: 493
-      - name: pcrf-config
+      - name: configs
         configMap:
-          name: pcrf
+          name: pcrf-configs
           defaultMode: 420
     {{- if .Values.config.coreDump.enabled }}
       - name: host-rootfs
diff --git a/omec/omec-control-plane/templates/statefulset-spgwc.yaml b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
index 3a387de..897131c 100644
--- a/omec/omec-control-plane/templates/statefulset-spgwc.yaml
+++ b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
@@ -92,10 +92,9 @@
 {{ toYaml .Values.resources.spgwc | indent 10 }}
       {{- end }}
         volumeMounts:
-        - name: cp-script
-          mountPath: /opt/cp/scripts/spgwc-run.sh
-          subPath: spgwc-run.sh
-        - name: cp-config
+        - name: scripts
+          mountPath: /opt/cp/scripts
+        - name: configs
           mountPath: /etc/cp/config
         - name: shared-app
           mountPath: /tmp
@@ -103,7 +102,6 @@
         - name: coredump
           mountPath: /tmp/coredump
       {{- end }}
-
       - name: gx-app
         image: {{ .Values.images.tags.spgwc }}
         imagePullPolicy: {{ .Values.images.pullPolicy }}
@@ -117,26 +115,14 @@
         command: ["bash", "-xc"]
         args:
         - /opt/cp/scripts/spgwc-run.sh gx-app
-        env:
-        - name: MEM_LIMIT
-          valueFrom:
-            resourceFieldRef:
-              containerName: spgwc
-              resource: limits.memory
-              divisor: 1Mi
-        - name: POD_IP
-          valueFrom:
-            fieldRef:
-              fieldPath: status.podIP
       {{- if .Values.resources.enabled }}
         resources:
 {{ toYaml .Values.resources.spgwc | indent 10 }}
       {{- end }}
         volumeMounts:
-        - name: cp-script
-          mountPath: /opt/cp/scripts/spgwc-run.sh
-          subPath: spgwc-run.sh
-        - name: cp-config
+        - name: scripts
+          mountPath: /opt/cp/scripts
+        - name: configs
           mountPath: /etc/cp/config
         - name: shared-app
           mountPath: /tmp
@@ -145,13 +131,13 @@
           mountPath: /tmp/coredump
       {{- end }}
       volumes:
-      - name: cp-script
+      - name: scripts
         configMap:
-          name: spgwc
+          name: spgwc-scripts
           defaultMode: 493
-      - name: cp-config
+      - name: configs
         configMap:
-          name: spgwc
+          name: spgwc-configs
           defaultMode: 420
       - name: shared-app
         emptyDir: {}