AETHER-3384 Allow external IP and various types for OMEC services

Change-Id: I95bb175d452d2c9e8e3610fb757cbfd9939731c9
diff --git a/omec-control-plane/templates/service-mme.yaml b/omec-control-plane/templates/service-mme.yaml
index b729ab2..512ea49 100644
--- a/omec-control-plane/templates/service-mme.yaml
+++ b/omec-control-plane/templates/service-mme.yaml
@@ -16,81 +16,55 @@
   labels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 spec:
+  type: {{ .Values.config.mme.serviceType }}
+{{- if .Values.config.mme.externalIP }}
+  externalIPs:
+    - {{ .Values.config.mme.externalIP }}
+{{- end }}
+{{- if eq .Values.config.mme.serviceType "LoadBalancer" }}
+{{- if .Values.config.mme.loadBalancerIP }}
+  loadBalancerIP: {{ .Values.config.mme.loadBalancerIP }}
+{{- end }}
+{{- end }}
   selector:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  type: ClusterIP
   ports:
     - name: s11
       port: {{ index $configJsonS11 "egtp_default_port" }}
       protocol: UDP
+{{- if eq .Values.config.mme.serviceType "NodePort" }}
+{{- if .Values.config.mme.s11.nodePort }}
+      nodePort: {{ .Values.config.mme.s11.nodePort }}
+{{- end }}
+{{- end }}
     - name: s6a
       port: 3868
       protocol: TCP
-    - name: s1ap
-      port: {{ index $configJsonS1ap "sctp_port" }}
-      protocol: SCTP
+{{- if eq .Values.config.mme.serviceType "NodePort" }}
+{{- if .Values.config.mme.s6a.nodePort }}
+      nodePort: {{ .Values.config.mme.s6a.nodePort }}
+{{- end }}
+{{- end }}
     - name: prometheus-exporter
       port: {{ .Values.config.mme.prometheus.port }}
       protocol: TCP
+{{- if eq .Values.config.mme.serviceType "NodePort" }}
+{{- if .Values.config.mme.prometheus.nodePort }}
+      nodePort: {{ .Values.config.mme.prometheus.nodePort }}
+{{- end }}
+{{- end }}
+    - name: s1ap
+      port: {{ index $configJsonS1ap "sctp_port" }}
+      protocol: SCTP
+{{- if eq .Values.config.mme.serviceType "NodePort" }}
+{{- if .Values.config.mme.s1ap.nodePort }}
+      nodePort: {{ .Values.config.mme.s1ap.nodePort }}
+{{- end }}
+{{- end }}
     - name: mme-app-config
       port: 8080
       protocol: TCP
     - name: mme-s1ap-config
       port: 8081
       protocol: TCP
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: mme-headless
-  labels:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-spec:
-  selector:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  clusterIP: None
-  ports:
-    - name: s11
-      port: {{ index $configJsonS11 "egtp_default_port" }}
-      protocol: UDP
-    - name: s6a
-      port: 3868
-      protocol: TCP
-    - name: s1ap
-      port: {{ index $configJsonS1ap "sctp_port" }}
-      protocol: SCTP
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: mme-external
-  labels:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-spec:
-  selector:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  type: NodePort
-  ports:
-  {{- if .Values.config.mme.prometheus.nodePort.enabled }}
-    - name: prometheus-exporter
-      port: {{ .Values.config.mme.prometheus.port }}
-      protocol: TCP
-      nodePort: {{ .Values.config.mme.prometheus.nodePort.port }}
-  {{- end }}
-  {{- if .Values.config.mme.s11.nodePort.enabled }}
-    - name: s11
-      port: {{ index $configJsonS11 "egtp_default_port" }}
-      protocol: UDP
-      nodePort: {{ .Values.config.mme.s11.nodePort.port }}
-  {{- end }}
-  {{- if .Values.config.mme.s6a.nodePort.enabled }}
-    - name: s6a
-      port: 3868
-      protocol: TCP
-      nodePort: {{ .Values.config.mme.s6a.nodePort.port }}
-  {{- end }}
-    - name: s1ap
-      port: {{ index $configJsonS1ap "sctp_port" }}
-      nodePort: {{ index $configJsonS1ap "sctp_port_external" }}
-      protocol: SCTP
 {{- end }}