EDGEPOD-85 Add ability to enable coredump for OMEC apps

Core files will be generated when config.coreDump.enabled is set to
true. Path of the generated core files can be configured by setting
config.coreDump.path, which is set to /tmp/coredump by default.

Change-Id: I5149751ba091a1f49e2eee91a14889898301a7bf
diff --git a/omec/omec-data-plane/templates/statefulset-spgwu.yaml b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
index 35b6304..f3452d4 100644
--- a/omec/omec-data-plane/templates/statefulset-spgwu.yaml
+++ b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
@@ -75,10 +75,21 @@
               mountPath: /opt/dp/scripts/setup-af-iface.sh
               subPath: setup-af-iface.sh
     {{- end }}
+    {{- if .Values.config.coreDump.enabled }}
+{{ tuple "spgwc" . | include "omec-data-plane.coredump_init" | indent 8 }}
+    {{- end }}
       containers:
       - name: spgwu
         image: {{ .Values.images.tags.spgwu | quote }}
         imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+        securityContext:
+      {{- if .Values.config.coreDump.enabled }}
+          privileged: true
+          runAsUser: 0
+      {{- end }}
+          capabilities:
+            add:
+              - IPC_LOCK
         stdin: true
         tty: true
         env:
@@ -104,6 +115,10 @@
           subPath: run.sh
         - name: dp-config
           mountPath: /etc/dp/config
+      {{- if .Values.config.coreDump.enabled }}
+        - name: coredump
+          mountPath: /tmp/coredump
+      {{- end }}
         resources:
           requests:
           {{- if .Values.resources.enabled }}
@@ -119,10 +134,6 @@
           {{- if .Values.config.sriov.enabled }}
             intel.com/sriov_vfio: 2
           {{- end }}
-        securityContext:
-          capabilities:
-            add:
-              - IPC_LOCK
       volumes:
       - name: dp-script
         configMap:
@@ -132,3 +143,11 @@
         configMap:
           name: spgwu
           defaultMode: 420
+    {{- if .Values.config.coreDump.enabled }}
+      - name: host-rootfs
+        hostPath:
+          path: /
+      - name: coredump
+        hostPath:
+          path: {{ .Values.config.coreDump.path }}
+    {{- end }}