EDGEPOD-60 Add support of multiple UPFs

- Enable configuring multiple UPF mode
- Add support of ZMQ mode when multple UPF enabled
- Change to create three types of services for each application,
  cluster IP, headless, and external

Change-Id: Ic004a4ff7cdc5708d28ce2717677041f71b4d819
diff --git a/omec/omec-data-plane/Chart.yaml b/omec/omec-data-plane/Chart.yaml
index 21f163a..1510a0b 100644
--- a/omec/omec-data-plane/Chart.yaml
+++ b/omec/omec-data-plane/Chart.yaml
@@ -19,4 +19,4 @@
 name: omec-data-plane
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.1.6
+version: 0.1.7
diff --git a/omec/omec-data-plane/templates/configmap-spgwu.yaml b/omec/omec-data-plane/templates/configmap-spgwu.yaml
index 3a589d0..81319c1 100644
--- a/omec/omec-data-plane/templates/configmap-spgwu.yaml
+++ b/omec/omec-data-plane/templates/configmap-spgwu.yaml
@@ -57,10 +57,20 @@
     MASTER_CDR=./cdr/master.csv
   interface.cfg: |
     [0]
+    zmq_protocol = tcp
     dp_comm_ip = DP_ADDR
     dp_comm_port = 20
+{{- if .Values.config.spgwu.multiUpfs }}
+    cp_nb_ip = {{ .Values.config.spgwu.cpComm.addr }}
+    cp_nb_port = {{ .Values.config.spgwu.cpComm.port }}
     cp_comm_ip = {{ .Values.config.spgwu.cpComm.addr }}
     cp_comm_port = {{ .Values.config.spgwu.cpComm.port }}
+    zmq_dp_ip=127.0.0.1
+    zmq_cp_ip=127.0.0.1
+{{- else }}
+    cp_comm_ip = {{ .Values.config.spgwu.cpComm.addr }}
+    cp_comm_port = {{ .Values.config.spgwu.cpComm.port }}
+{{- end }}
 {{- 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/service-spgwu.yaml b/omec/omec-data-plane/templates/service-spgwu.yaml
index 22c212b..6985e22 100644
--- a/omec/omec-data-plane/templates/service-spgwu.yaml
+++ b/omec/omec-data-plane/templates/service-spgwu.yaml
@@ -19,19 +19,54 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: spgwu-dp-comm
+  name: spgwu
   labels:
 {{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
 spec:
   selector:
 {{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
-{{- if .Values.config.spgwu.dpComm.nodePort.enabled }}
-  type: NodePort
-{{- end }}
   ports:
   - name: dp-comm
-    port: 20
+    port: {{ .Values.config.spgwu.dpComm.port }}
+{{- if .Values.config.spgwu.multiUpfs }}
+    protocol: TCP
+{{- else }}
     protocol: UDP
-  {{- if .Values.config.spgwu.dpComm.nodePort.enabled }}
+{{- end }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: spgwu-headless
+  labels:
+{{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
+spec:
+  clusterIP: None
+  selector:
+{{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
+  ports:
+  - name: dp-comm
+    port: {{ .Values.config.spgwu.dpComm.port }}
+{{- if .Values.config.spgwu.multiUpfs }}
+    protocol: TCP
+{{- else }}
+    protocol: UDP
+{{- end }}
+{{- if and (not .Values.config.spgwu.multiUpfs) .Values.config.spgwu.dpComm.nodePort.enabled }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: spgwu-external
+  labels:
+{{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
+  type: NodePort
+  ports:
+  - name: dp-comm
+    port: {{ .Values.config.spgwu.dpComm.port }}
+    protocol: UDP
     nodePort: {{ .Values.config.spgwu.dpComm.nodePort.port }}
-  {{- end }}
+{{- end }}
diff --git a/omec/omec-data-plane/templates/statefulset-spgwu.yaml b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
index 11749e7..07f9082 100644
--- a/omec/omec-data-plane/templates/statefulset-spgwu.yaml
+++ b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
@@ -19,6 +19,7 @@
 kind: StatefulSet
 metadata:
   name: spgwu
+  serviceName: spgwu-headless
   labels:
 {{ tuple "spgwu" . | include "omec-data-plane.metadata_labels" | indent 4 }}
 spec:
diff --git a/omec/omec-data-plane/values.yaml b/omec/omec-data-plane/values.yaml
index 78a69dc..0089751 100644
--- a/omec/omec-data-plane/values.yaml
+++ b/omec/omec-data-plane/values.yaml
@@ -48,17 +48,22 @@
     sgi:
       device: sgi-net
       ip: 13.1.1.3/24
+    # Note that zmq is used for cp-dp commmunication when multiple UPFs is set
+    # Otherwise, direct UDP communication is used
+    # TODO: unify cp-dp comm to ZMQ for both multi and single UPF scenario
+    multiUpfs: true
     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-cp-comm
+      addr: spgwc
       port: 21
     dpComm:
       nodePort:
         enabled: false
         port: 30020
+      port: 20
     # Set "--no-pci --vdev eth_af_packet0,iface=s1u-net --vdev eth_af_packet1,iface=sgi-net"
     # when sriov is disabled
     devices: ""