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

Change-Id: I8a726b94f2bd958a814d229e182d6cf7f1f6feed
diff --git a/omec/omec-control-plane/Chart.yaml b/omec/omec-control-plane/Chart.yaml
index d582eed..0c673d8 100644
--- a/omec/omec-control-plane/Chart.yaml
+++ b/omec/omec-control-plane/Chart.yaml
@@ -10,4 +10,4 @@
 name: omec-control-plane
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.2.7
+version: 0.3.0
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:
diff --git a/omec/omec-control-plane/values.yaml b/omec/omec-control-plane/values.yaml
index 81dc1d7..920f3a8 100644
--- a/omec/omec-control-plane/values.yaml
+++ b/omec/omec-control-plane/values.yaml
@@ -10,7 +10,6 @@
     hssdb: docker.io/omecproject/c3po-hssdb:master-latest
     hss: docker.io/omecproject/c3po-hss:master-latest
     mme: docker.io/omecproject/nucleus:master-latest
-    mmeExporter: docker.io/omecproject/mme-exporter:paging-latest
     spgwc: docker.io/omecproject/spgw:master-latest
     depCheck: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
   pullPolicy: IfNotPresent
@@ -89,6 +88,11 @@
       nodePort:
         enabled: false
         port: 33868
+    prometheus:
+      port: 9089
+      nodePort:
+        enabled: false
+        port: 30086
     # Provide the peer whitelist extension
     # The peer name must be a fqdn. We allow also a special "*" character as the
     # first label of the fqdn, to allow all fqdn with the same domain name.
@@ -193,6 +197,11 @@
       nodePort:
         enabled: false
         port: 33869
+    prometheus:
+      port: 3081
+      nodePort:
+        enabled: false
+        port: 30085
     # See https://github.com/omec-project/openmme/blob/master/README.txt for more config options
     cfgFiles:
       config.json:
@@ -232,19 +241,6 @@
           # host and realm will be set dynamically if unset
           #host:
           #realm:
-      mme_exporter.json:
-        edges:
-        - id: onf-menlo
-          tac: 202
-          edgeName: edge-onf-menlo
-        - id: oaisim
-          tac: 1
-          edgeName: edge-oaisim
-        phoneTypes:
-        - imsi: 208014567891200
-          phoneType: "Pixel-4"
-        - imsi: 208014567891201
-          phoneType: "iPhone11-Pro"
   spgwc:
     deploy: true
     pfcp: true
@@ -282,6 +278,11 @@
     dpComm:
       addr: spgwu
       port: 20
+    prometheus:
+      port: 9089
+      nodePort:
+        enabled: false
+        port: 30084
     jsonCfgFiles:
       subscriber_mapping.json:
         subscriber-selection-rules:
@@ -406,8 +407,3 @@
         LOCAL_HIGH_LIMIT_PORT = 65535
         REMOTE_LOW_LIMIT_PORT = 0
         REMOTE_HIGH_LIMIT_PORT = 65535
-
-prometheusExporter:
-  mme:
-    enabled: true # if it is set to false, subscriber-monitoring will not be operational
-    port: 33081 # for NodePort