AETHER-2075 [5g-control-plane] Fix monitoring target down alerts

Removed Prometheus service monitor annotation and ports for unimplemented NFs.
Also, refactored Service template.

Change-Id: I105e4ae05baf4f819c881c7e1c6b74064b0a7d6b
diff --git a/omec/5g-control-plane/templates/service-amf.yaml b/omec/5g-control-plane/templates/service-amf.yaml
index 6900dba..d02f57f 100644
--- a/omec/5g-control-plane/templates/service-amf.yaml
+++ b/omec/5g-control-plane/templates/service-amf.yaml
@@ -13,29 +13,7 @@
   labels:
 {{ tuple "amf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
-  selector:
-{{ tuple "amf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.amf.prometheus.port }}
-    protocol: TCP
-  - name: sbi
-    port: {{ .Values.config.amf.sbi.port }}
-    protocol: TCP
-  - name: ngapp
-    port: {{ .Values.config.amf.ngapp.port }}
-    protocol: SCTP
-{{- if or .Values.config.amf.prometheus.nodePort.enabled .Values.config.amf.sbi.nodePort.enabled .Values.config.amf.ngapp.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: amf-external
-  labels:
-{{ tuple "amf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
+  type: {{ .Values.config.amf.serviceType }}
 {{- if .Values.config.amf.ngapp.externalIp }}
   externalIPs:
     - {{ .Values.config.amf.ngapp.externalIp }}
@@ -43,23 +21,28 @@
   selector:
 {{ tuple "amf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-{{- if .Values.config.amf.prometheus.nodePort.enabled }}
   - name: prometheus-exporter
     port: {{ .Values.config.amf.prometheus.port }}
     protocol: TCP
-    nodePort: {{ .Values.config.amf.prometheus.nodePort.port }}
+{{- if eq .Values.config.amf.serviceType "NodePort" }}
+{{- if .Values.config.amf.prometheus.nodePort }}
+    nodePort: {{ .Values.config.amf.prometheus.nodePort }}
 {{- end }}
-{{- if .Values.config.amf.sbi.nodePort.enabled }}
+{{- end }}
   - name: sbi
     port: {{ .Values.config.amf.sbi.port }}
     protocol: TCP
-    nodePort: {{ .Values.config.amf.sbi.nodePort.port }}
+{{- if eq .Values.config.amf.serviceType "NodePort" }}
+{{- if .Values.config.amf.sbi.nodePort }}
+    nodePort: {{ .Values.config.amf.sbi.nodePort }}
 {{- end }}
-{{- if .Values.config.amf.ngapp.nodePort.enabled }}
+{{- end }}
   - name: ngapp
     port: {{ .Values.config.amf.ngapp.port }}
     protocol: SCTP
-    nodePort: {{ .Values.config.amf.ngapp.nodePort.port }}
+{{- if eq .Values.config.amf.serviceType "NodePort" }}
+{{- if .Values.config.amf.ngapp.nodePort }}
+    nodePort: {{ .Values.config.amf.ngapp.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-ausf.yaml b/omec/5g-control-plane/templates/service-ausf.yaml
index defa18f..a7c815d 100644
--- a/omec/5g-control-plane/templates/service-ausf.yaml
+++ b/omec/5g-control-plane/templates/service-ausf.yaml
@@ -13,40 +13,16 @@
   labels:
 {{ tuple "ausf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.ausf.serviceType }}
   selector:
 {{ tuple "ausf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.ausf.prometheus.port }}
-    protocol: TCP
   - name: sbi
     port: {{ .Values.config.ausf.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.ausf.prometheus.nodePort.enabled .Values.config.ausf.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: ausf-external
-  labels:
-{{ tuple "ausf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "ausf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.ausf.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.ausf.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.ausf.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.ausf.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.ausf.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.ausf.sbi.nodePort.port }}
+{{- if eq .Values.config.ausf.serviceType "NodePort" }}
+{{- if .Values.config.ausf.sbi.nodePort }}
+    nodePort: {{ .Values.config.ausf.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-nrf.yaml b/omec/5g-control-plane/templates/service-nrf.yaml
index cbe45d1..07fcfe3 100644
--- a/omec/5g-control-plane/templates/service-nrf.yaml
+++ b/omec/5g-control-plane/templates/service-nrf.yaml
@@ -13,31 +13,16 @@
   labels:
 {{ tuple "nrf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.nrf.serviceType }}
   selector:
 {{ tuple "nrf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
   - name: sbi
     port: {{ .Values.config.nrf.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.nrf.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: nrf-external
-  labels:
-{{ tuple "nrf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "nrf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.nrf.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.nrf.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.nrf.sbi.nodePort.port }}
+{{- if eq .Values.config.nrf.serviceType "NodePort" }}
+{{- if .Values.config.nrf.sbi.nodePort }}
+    nodePort: {{ .Values.config.nrf.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-nssf.yaml b/omec/5g-control-plane/templates/service-nssf.yaml
index d92d524..4bcfcde 100644
--- a/omec/5g-control-plane/templates/service-nssf.yaml
+++ b/omec/5g-control-plane/templates/service-nssf.yaml
@@ -13,40 +13,16 @@
   labels:
 {{ tuple "nssf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.nssf.serviceType }}
   selector:
 {{ tuple "nssf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.nssf.prometheus.port }}
-    protocol: TCP
   - name: sbi
     port: {{ .Values.config.nssf.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.nssf.prometheus.nodePort.enabled .Values.config.nssf.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: nssf-external
-  labels:
-{{ tuple "nssf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "nssf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.nssf.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.nssf.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.nssf.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.nssf.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.nssf.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.nssf.sbi.nodePort.port }}
+{{- if eq .Values.config.nssf.serviceType "NodePort" }}
+{{- if .Values.config.nssf.sbi.nodePort }}
+    nodePort: {{ .Values.config.nssf.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-pcf.yaml b/omec/5g-control-plane/templates/service-pcf.yaml
index 69724df..1f9f7c4 100644
--- a/omec/5g-control-plane/templates/service-pcf.yaml
+++ b/omec/5g-control-plane/templates/service-pcf.yaml
@@ -13,40 +13,16 @@
   labels:
 {{ tuple "pcf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.pcf.serviceType }}
   selector:
 {{ tuple "pcf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.pcf.prometheus.port }}
-    protocol: TCP
   - name: sbi
     port: {{ .Values.config.pcf.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.pcf.prometheus.nodePort.enabled .Values.config.pcf.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: pcf-external
-  labels:
-{{ tuple "pcf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "pcf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.pcf.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.pcf.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.pcf.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.pcf.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.pcf.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.pcf.sbi.nodePort.port }}
+{{- if eq .Values.config.pcf.serviceType "NodePort" }}
+{{- if .Values.config.pcf.sbi.nodePort }}
+    nodePort: {{ .Values.config.pcf.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-smf.yaml b/omec/5g-control-plane/templates/service-smf.yaml
index 8e9d50d..6141455 100644
--- a/omec/5g-control-plane/templates/service-smf.yaml
+++ b/omec/5g-control-plane/templates/service-smf.yaml
@@ -13,49 +13,32 @@
   labels:
 {{ tuple "smf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.smf.serviceType }}
   selector:
 {{ tuple "smf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
   - name: pfcp
     port: {{ .Values.config.smf.n4.port }}
     protocol: UDP
+{{- if eq .Values.config.smf.serviceType "NodePort" }}
+{{- if .Values.config.smf.n4.nodePort }}
+    nodePort: {{ .Values.config.smf.n4.nodePort }}
+{{- end }}
+{{- end }}
   - name: prometheus-exporter
     port: {{ .Values.config.smf.prometheus.port }}
     protocol: TCP
+{{- if eq .Values.config.smf.serviceType "NodePort" }}
+{{- if .Values.config.smf.prometheus.nodePort }}
+    nodePort: {{ .Values.config.smf.prometheus.nodePort }}
+{{- end }}
+{{- end }}
   - name: sbi
     port: {{ .Values.config.smf.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.smf.n4.nodePort.enabled .Values.config.smf.prometheus.nodePort.enabled .Values.config.smf.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: smf-external
-  labels:
-{{ tuple "smf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "smf" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.smf.n4.nodePort.enabled }}
-  - name: pfcp
-    port: {{ .Values.config.smf.n4.port }}
-    protocol: UDP
-    nodePort: {{ .Values.config.smf.n4.nodePort.port }}
-{{- end }}
-{{- if .Values.config.smf.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.smf.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.smf.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.smf.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.smf.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.smf.sbi.nodePort.port }}
+{{- if eq .Values.config.smf.serviceType "NodePort" }}
+{{- if .Values.config.smf.sbi.nodePort }}
+    nodePort: {{ .Values.config.smf.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-udm.yaml b/omec/5g-control-plane/templates/service-udm.yaml
index c2269b7..fe6fdd9 100644
--- a/omec/5g-control-plane/templates/service-udm.yaml
+++ b/omec/5g-control-plane/templates/service-udm.yaml
@@ -13,40 +13,16 @@
   labels:
 {{ tuple "udm" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.udm.serviceType }}
   selector:
 {{ tuple "udm" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.udm.prometheus.port }}
-    protocol: TCP
   - name: sbi
     port: {{ .Values.config.udm.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.udm.prometheus.nodePort.enabled .Values.config.udm.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: udm-external
-  labels:
-{{ tuple "udm" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "udm" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.udm.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.udm.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.udm.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.udm.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.udm.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.udm.sbi.nodePort.port }}
+{{- if eq .Values.config.udm.serviceType "NodePort" }}
+{{- if .Values.config.udm.sbi.nodePort }}
+    nodePort: {{ .Values.config.udm.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-udr.yaml b/omec/5g-control-plane/templates/service-udr.yaml
index 44e0c82..3c13170 100644
--- a/omec/5g-control-plane/templates/service-udr.yaml
+++ b/omec/5g-control-plane/templates/service-udr.yaml
@@ -13,40 +13,16 @@
   labels:
 {{ tuple "udr" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.udr.serviceType }}
   selector:
 {{ tuple "udr" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.udr.prometheus.port }}
-    protocol: TCP
   - name: sbi
     port: {{ .Values.config.udr.sbi.port }}
     protocol: TCP
-{{- if or .Values.config.udr.prometheus.nodePort.enabled .Values.config.udr.sbi.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: udr-external
-  labels:
-{{ tuple "udr" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "udr" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.udr.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.udr.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.udr.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.udr.sbi.nodePort.enabled }}
-  - name: sbi
-    port: {{ .Values.config.udr.sbi.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.udr.sbi.nodePort.port }}
+{{- if eq .Values.config.udr.serviceType "NodePort" }}
+{{- if .Values.config.udr.sbi.nodePort }}
+    nodePort: {{ .Values.config.udr.sbi.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}
diff --git a/omec/5g-control-plane/templates/service-webui.yaml b/omec/5g-control-plane/templates/service-webui.yaml
index 0afc3dc..b91e094 100644
--- a/omec/5g-control-plane/templates/service-webui.yaml
+++ b/omec/5g-control-plane/templates/service-webui.yaml
@@ -13,43 +13,24 @@
   labels:
 {{ tuple "webui" . | include "5g-control-plane.metadata_labels" | indent 4 }}
 spec:
-  type: ClusterIP
+  type: {{ .Values.config.webui.serviceType }}
   selector:
 {{ tuple "webui" . | include "5g-control-plane.metadata_labels" | indent 4 }}
   ports:
-  - name: prometheus-exporter
-    port: {{ .Values.config.webui.prometheus.port }}
-    protocol: TCP
   - name: urlport-http
     port: {{ .Values.config.webui.urlport.port }}
     protocol: TCP
+{{- if eq .Values.config.webui.serviceType "NodePort" }}
+{{- if .Values.config.webui.urlport.nodePort }}
+    nodePort: {{ .Values.config.webui.urlport.nodePort }}
+{{- end }}
+{{- end }}
   - name: grpc
     port: {{ .Values.config.webui.grpc.port }}
     protocol: TCP
-{{- if or .Values.config.webui.urlport.nodePort.enabled .Values.config.webui.prometheus.nodePort.enabled }}
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: webui-external
-  labels:
-{{ tuple "webui" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-spec:
-  type: NodePort
-  selector:
-{{ tuple "webui" . | include "5g-control-plane.metadata_labels" | indent 4 }}
-  ports:
-{{- if .Values.config.webui.prometheus.nodePort.enabled }}
-  - name: prometheus-exporter
-    port: {{ .Values.config.webui.prometheus.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.webui.prometheus.nodePort.port }}
-{{- end }}
-{{- if .Values.config.webui.urlport.nodePort.enabled }}
-  - name: urlport-http
-    port: {{ .Values.config.webui.urlport.port }}
-    protocol: TCP
-    nodePort: {{ .Values.config.webui.urlport.nodePort.port }}
+{{- if eq .Values.config.webui.serviceType "NodePort" }}
+{{- if .Values.config.webui.grpc.nodePort }}
+    nodePort: {{ .Values.config.webui.grpc.nodePort }}
 {{- end }}
 {{- end }}
 {{- end }}