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-control-plane/values.yaml b/omec/omec-control-plane/values.yaml
index 2c83ee6..2567a38 100644
--- a/omec/omec-control-plane/values.yaml
+++ b/omec/omec-control-plane/values.yaml
@@ -115,5 +115,5 @@
   spgwc:
     # make it global
     spgwu:
-      addr: spgwu
+      addr: spgwu-dp-comm
       port: 20
diff --git a/omec/omec-data-plane/Chart.yaml b/omec/omec-data-plane/Chart.yaml
index b1480f3..e82cc85 100644
--- a/omec/omec-data-plane/Chart.yaml
+++ b/omec/omec-data-plane/Chart.yaml
@@ -18,4 +18,4 @@
 appVersion: "1.0"
 description: OMEC data plane services
 name: omec-data-plane
-version: 0.1.1
+version: 0.1.2
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
diff --git a/omec/omec-data-plane/values.yaml b/omec/omec-data-plane/values.yaml
index 60a454b..3738e9f 100644
--- a/omec/omec-data-plane/values.yaml
+++ b/omec/omec-data-plane/values.yaml
@@ -41,23 +41,24 @@
 config:
   sriov:
     enabled: true
+    # Provide interface used as a SR-IOV PF
+    # If your cluster has multiple nodes with different interface names,
+    # simply provide the whole list
     resourceList:
-      - resourceName: sriov_vfio
-        selectors:
-          pfNames:
-            - eno1
-          drivers:
-            - vfio-pci
-      - resourceName: sriov_netdevice
-        selectors:
-          pfNames:
-            - eno1
-          drivers:
-            - ixgbevf
+      # Provide PF name with its VFs are bounded to vfio-pci driver
+      vfio:
+        pfNames:
+          - eno1
+      # Provide PF name with its VFs bounded to PF's driver
+      # The driver name must be specified to prevent one interface is
+      # registered to both vfio and netdevice resource pools
+      # NOTE: netDevice is required to use CDN service
+      #netDevice:
+      #  pfNames:
+      #    - eno2
+      #  drivers:
+      #    - ixgbevf
   spgwu:
-    spgwc:
-      addr: spgwc
-      port: 21
     # Provide the S1U and SGI networks facing device name and IP address
     s1u:
       device: s1u-net
@@ -65,6 +66,17 @@
     sgi:
       device: sgi-net
       ip: 13.1.1.3/24
+    cpComm:
+      # IMPORTANT: when you deploy CP and DP to separate clusters, enable nodePort
+      # from both cpComm(omec-control-plane) and dpComm(omec-data-plane) and
+      # set "addr" to remote cluster's entry node IP and
+      # "port" to cpComm.nodePort.port value configured in omec-control-plane.
+      addr: spgwc
+      port: 21
+    dpComm:
+      nodePort:
+        enabled: false
+        port: 30020
     # Set "--no-pci --vdev eth_af_packet0,iface=s1u-net --vdev eth_af_packet1,iface=sgi-net"
     # when sriov is disabled
     devices: ""