AETHER-572 Expose prometheus exporter ports for OMEC control plane services

Change-Id: I8a726b94f2bd958a814d229e182d6cf7f1f6feed
diff --git a/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl b/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
index 8ece24f..256da0d 100644
--- a/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
@@ -33,7 +33,6 @@
 cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s1ap.json
 cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s6a.json
 cp /opt/mme/config/s6a_fd.conf /opt/mme/config/shared/s6a_fd.conf
-cp /opt/mme/config/mme_exporter.json /opt/mme/config/shared/mme_exporter.json
 
 #This multiple copies of config needs some cleanup. For now I want 
 #that after running mme_init config to be present in the target directory
diff --git a/omec/omec-control-plane/templates/configmap-hss.yaml b/omec/omec-control-plane/templates/configmap-hss.yaml
index 7e2dc5d..8e9c06a 100644
--- a/omec/omec-control-plane/templates/configmap-hss.yaml
+++ b/omec/omec-control-plane/templates/configmap-hss.yaml
@@ -13,6 +13,7 @@
 {{- $hssJsonCommon := index $hssJson "common" }}
 {{- $hssJsonHss := index $hssJson "hss" }}
 
+{{- $_ := .Values.config.hss.prometheus.port | set $hssJsonCommon "prom_port" -}}
 {{- if not (hasKey $hssJsonCommon "originhost") -}}
 {{- $_ := tuple "hss" "identity" . | include "omec-control-plane.diameter_endpoint" | set $hssJsonCommon "originhost" -}}
 {{- end }}
@@ -97,6 +98,7 @@
   hss-bootstrap.sh: |
 {{ tuple "bin/_hss-bootstrap.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- range $key, $value := .Values.config.hss.cfgFiles }}
-  {{ $key }}: {{ toJson $value | quote }}
+  {{ $key }}: |-
+{{ toPrettyJson $value | indent 4 }}
 {{- end }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-mme.yaml b/omec/omec-control-plane/templates/configmap-mme.yaml
index bc5db25..57624c7 100644
--- a/omec/omec-control-plane/templates/configmap-mme.yaml
+++ b/omec/omec-control-plane/templates/configmap-mme.yaml
@@ -6,8 +6,10 @@
 
 {{- if .Values.config.mme.deploy }}
 {{- $configJson := index .Values.config.mme.cfgFiles "config.json" }}
+{{- $configJsonMme := index $configJson "mme" }}
 {{- $configJsonS6a := index $configJson "s6a" }}
 
+{{- $_ := .Values.config.mme.prometheus.port | set $configJsonMme "prom_port" -}}
 {{- if not (hasKey $configJsonS6a "host") -}}
 {{- $_ := tuple "hss" "identity" . | include "omec-control-plane.diameter_endpoint" | set $configJsonS6a "host" -}}
 {{- end }}
@@ -84,6 +86,7 @@
   mme-run.sh: |
 {{ tuple "bin/_mme-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
 {{- range $key, $value := .Values.config.mme.cfgFiles }}
-  {{ $key }}: {{ toJson $value | quote }}
+  {{ $key }}: |-
+{{ toPrettyJson $value | indent 4 }}
 {{- end }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-spgwc.yaml b/omec/omec-control-plane/templates/configmap-spgwc.yaml
index 030a09a..4e3ebef 100644
--- a/omec/omec-control-plane/templates/configmap-spgwc.yaml
+++ b/omec/omec-control-plane/templates/configmap-spgwc.yaml
@@ -26,6 +26,7 @@
     PFCP_PORT = 8805
     UPF_PFCP_IP = 127.0.0.1
     UPF_PFCP_PORT = 8805
+    PROMETHEUS_PORT = {{ .Values.config.spgwc.prometheus.port }}
     TRANSMIT_TIMER = 2
     PERIODIC_TIMER = 10
     TRANSMIT_COUNT = 5
@@ -90,6 +91,7 @@
 {{ $value | indent 4 }}
 {{- end }}
 {{- range $key, $value := .Values.config.spgwc.jsonCfgFiles }}
-  {{ $key }}: {{ toJson $value | quote }}
+  {{ $key }}: |-
+{{ toPrettyJson $value | indent 4 }}
 {{- end }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/service-hss.yaml b/omec/omec-control-plane/templates/service-hss.yaml
index fad2a27..dea1e7a 100644
--- a/omec/omec-control-plane/templates/service-hss.yaml
+++ b/omec/omec-control-plane/templates/service-hss.yaml
@@ -19,6 +19,9 @@
   - name: s6a
     port: 3868
     protocol: TCP
+  - name: prometheus-exporter
+    port: {{ .Values.config.hss.prometheus.port }}
+    protocol: TCP
 ---
 apiVersion: v1
 kind: Service
@@ -47,6 +50,12 @@
 {{ tuple "hss" . | include "omec-control-plane.metadata_labels" | indent 4 }}
   type: NodePort
   ports:
+  {{- if .Values.config.hss.prometheus.nodePort.enabled }}
+    - name: prometheus-exporter
+      port: {{ .Values.config.hss.prometheus.port }}
+      protocol: TCP
+      nodePort: {{ .Values.config.hss.prometheus.nodePort.port }}
+  {{- end }}
   - name: s6a
     port: 3868
     protocol: TCP
diff --git a/omec/omec-control-plane/templates/service-mme.yaml b/omec/omec-control-plane/templates/service-mme.yaml
index 1d112e6..69e8af7 100644
--- a/omec/omec-control-plane/templates/service-mme.yaml
+++ b/omec/omec-control-plane/templates/service-mme.yaml
@@ -29,11 +29,9 @@
     - name: s1ap
       port: {{ index $configJsonS1ap "sctp_port" }}
       protocol: SCTP
-{{- if .Values.prometheusExporter.mme.enabled }}
-    - name: exporter
-      port: 3081
+    - name: prometheus-exporter
+      port: {{ .Values.config.mme.prometheus.port }}
       protocol: TCP
-{{- end }}
 ---
 apiVersion: v1
 kind: Service
@@ -67,6 +65,12 @@
 {{ 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" }}
@@ -83,10 +87,4 @@
       port: {{ index $configJsonS1ap "sctp_port" }}
       nodePort: {{ index $configJsonS1ap "sctp_port_external" }}
       protocol: SCTP
-  {{- if .Values.prometheusExporter.mme.enabled }}
-    - name: exporter
-      port: 3081
-      nodePort: {{ .Values.prometheusExporter.mme.port }}
-      protocol: TCP
-  {{- end }}
 {{- end }}
diff --git a/omec/omec-control-plane/templates/service-spgwc.yaml b/omec/omec-control-plane/templates/service-spgwc.yaml
index aeb8f5b..5dd3ba4 100644
--- a/omec/omec-control-plane/templates/service-spgwc.yaml
+++ b/omec/omec-control-plane/templates/service-spgwc.yaml
@@ -27,6 +27,9 @@
   - name: s11
     port: {{ .Values.config.spgwc.s11.port }}
     protocol: UDP
+  - name: prometheus-exporter
+    port: {{ .Values.config.spgwc.prometheus.port }}
+    protocol: TCP
 ---
 apiVersion: v1
 kind: Service
@@ -63,6 +66,12 @@
   selector:
 {{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
   ports:
+{{- if .Values.config.spgwc.prometheus.nodePort.enabled }}
+  - name: prometheus-exporter
+    port: {{ .Values.config.spgwc.prometheus.port }}
+    protocol: TCP
+    nodePort: {{ .Values.config.spgwc.prometheus.nodePort.port }}
+{{- end }}
 {{- if .Values.config.spgwc.cpComm.nodePort.enabled }}
   - name: cp-comm
     port: {{ .Values.config.spgwc.cpComm.port }}
diff --git a/omec/omec-control-plane/templates/statefulset-mme.yaml b/omec/omec-control-plane/templates/statefulset-mme.yaml
index 0d47a40..1146930 100644
--- a/omec/omec-control-plane/templates/statefulset-mme.yaml
+++ b/omec/omec-control-plane/templates/statefulset-mme.yaml
@@ -226,28 +226,6 @@
         - name: coredump
           mountPath: /tmp/coredump
       {{- end }}
-    {{- if .Values.prometheusExporter.mme.enabled }}
-      - name: subscriber-exporter
-        image: {{ .Values.images.tags.mmeExporter }}
-        imagePullPolicy: {{ .Values.images.pullPolicy }}
-        securityContext:
-          privileged: true
-        command: ["bash", "-xc"]
-        args:
-        - cp /opt/mme/config/shared/mme_exporter.json /openmme/conf/mme_exporter.json;
-          until [ -e /tmp/unix_socket ]; do sleep 1; done;
-          chmod 777 /tmp/unix_socket;
-          while true; do python3 monitor_client.py; sleep 1; done;
-        {{- if .Values.resources.enabled }}
-        resources:
-{{ toYaml .Values.resources.mme | indent 10 }}
-        {{- end }}
-        volumeMounts:
-        - name: shared-data
-          mountPath: /opt/mme/config/shared
-        - name: shared-app
-          mountPath: /tmp
-    {{- end }}
       volumes:
       - name: scripts
         configMap: