COMAC-168,COMAC-171 [omec-dp] Change sriov configs and enable nodePort

- Change sriov configs to help user configure more easily
- Enable nodePort for CP-DP communication when CP and DP are deployed in
  separate clusters, diabled by default

Change-Id: I0e2520d66f2240a2888673d930487dcf112861a0
diff --git a/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl b/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl
index 9c185c0..ff0e476 100644
--- a/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl
+++ b/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl
@@ -17,12 +17,11 @@
 
 set -ex
 
-RUN_DIR=${RUN_DIR:-"/opt/dp"}
-mkdir -p $RUN_DIR/config
-cd $RUN_DIR/config
+mkdir -p /opt/dp/config
+cd /opt/dp/config
 cp /etc/dp/config/{cdr.cfg,dp_config.cfg,interface.cfg} .
 
-sed -i "s/DP_ADDR/$DP_ADDR/g" interface.cfg
+sed -i "s/DP_ADDR/$POD_IP/g" interface.cfg
 
 source dp_config.cfg
 ngic_dataplane $EAL_ARGS -- $APP_ARGS
diff --git a/omec/omec-data-plane/templates/configmap-spgwu.yaml b/omec/omec-data-plane/templates/configmap-spgwu.yaml
index c2698ae..3a589d0 100644
--- a/omec/omec-data-plane/templates/configmap-spgwu.yaml
+++ b/omec/omec-data-plane/templates/configmap-spgwu.yaml
@@ -14,6 +14,7 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 */}}
+
 ---
 apiVersion: v1
 kind: ConfigMap
@@ -58,8 +59,8 @@
     [0]
     dp_comm_ip = DP_ADDR
     dp_comm_port = 20
-    cp_comm_ip = {{ .Values.config.spgwu.spgwc.addr }}
-    cp_comm_port = {{ .Values.config.spgwu.spgwc.port }}
+    cp_comm_ip = {{ .Values.config.spgwu.cpComm.addr }}
+    cp_comm_port = {{ .Values.config.spgwu.cpComm.port }}
 {{- if not .Values.config.sriov.enabled }}
   setup-af-iface.sh: |
 {{ tuple "bin/_spgwu-setup-af-iface.sh.tpl" . | include "omec-data-plane.template" | indent 4 }}
diff --git a/omec/omec-data-plane/templates/configmap-sriov-conf.yaml b/omec/omec-data-plane/templates/configmap-sriov-conf.yaml
index 4b8fd9a..655d200 100644
--- a/omec/omec-data-plane/templates/configmap-sriov-conf.yaml
+++ b/omec/omec-data-plane/templates/configmap-sriov-conf.yaml
@@ -24,6 +24,24 @@
 data:
   config.json: |
     {
-      "resourceList": {{ toJson .Values.config.sriov.resourceList }}
+      "resourceList": [
+        {
+          "resourceName": "sriov_vfio",
+          "selectors": {
+              "pfNames": {{ toJson .Values.config.sriov.resourceList.vfio.pfNames }},
+              "drivers": ["vfio-pci"]
+          }
+        }
+{{- if hasKey .Values.config.sriov.resourceList "netDevice" }}
+        ,
+        {
+          "resourceName": "sriov_netdevice",
+          "selectors": {
+              "pfNames": {{ toJson .Values.config.sriov.resourceList.netDevice.pfNames }},
+              "drivers": {{ toJson .Values.config.sriov.resourceList.netDevice.drivers }}
+          }
+        }
+{{- end }}
+      ]
     }
 {{- end }}
diff --git a/omec/omec-data-plane/templates/daemonset-sriov-dp.yaml b/omec/omec-data-plane/templates/daemonset-sriov-dp.yaml
index ad22876..ca75a36 100644
--- a/omec/omec-data-plane/templates/daemonset-sriov-dp.yaml
+++ b/omec/omec-data-plane/templates/daemonset-sriov-dp.yaml
@@ -38,7 +38,7 @@
         imagePullPolicy: {{ .Values.images.pullPolicy }}
         command: [ "bash", "-c" ]
         args:
-        - cp /tmp/cni/bin/{sriov,vfioveth,static} /host/opt/cni/bin/
+        - cp /tmp/cni/bin/{sriov,vfioveth,jq,static} /host/opt/cni/bin/
         volumeMounts:
         - name: cni-bin
           mountPath: /host/opt/cni/bin
diff --git a/omec/omec-data-plane/templates/service-spgwu.yaml b/omec/omec-data-plane/templates/service-spgwu.yaml
index dd4766e..22c212b 100644
--- a/omec/omec-data-plane/templates/service-spgwu.yaml
+++ b/omec/omec-data-plane/templates/service-spgwu.yaml
@@ -19,12 +19,19 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: spgwu
+  name: spgwu-dp-comm
+  labels:
+{{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
 spec:
   selector:
 {{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
-  clusterIP: None
+{{- if .Values.config.spgwu.dpComm.nodePort.enabled }}
+  type: NodePort
+{{- end }}
   ports:
-  - name: cpdp
+  - name: dp-comm
     port: 20
     protocol: UDP
+  {{- if .Values.config.spgwu.dpComm.nodePort.enabled }}
+    nodePort: {{ .Values.config.spgwu.dpComm.nodePort.port }}
+  {{- end }}
diff --git a/omec/omec-data-plane/templates/statefulset-spgwu.yaml b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
index 21e8d57..11749e7 100644
--- a/omec/omec-data-plane/templates/statefulset-spgwu.yaml
+++ b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
@@ -26,7 +26,6 @@
   selector:
     matchLabels:
 {{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 6 }}
-  serviceName: spgwu
   template:
     metadata:
       labels:
@@ -88,7 +87,7 @@
               containerName: spgwu
               resource: limits.memory
               divisor: 1Mi
-        - name: DP_ADDR
+        - name: POD_IP
           valueFrom:
             fieldRef:
               fieldPath: status.podIP