Start config4g pod which handles the configuration for 4G network
functions. Config4G receives configuration from simapp/ROC. Config4G
also does the health check for 4G network functions. Send config
if 4G network function is restarted.

Change-Id: I674d0bed095d5c3cbeffb2992a4fccdbbb662509
diff --git a/omec/omec-control-plane/Chart.yaml b/omec/omec-control-plane/Chart.yaml
index ce62e09..5d89bd3 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.6.16
+version: 0.6.17
diff --git a/omec/omec-control-plane/templates/bin/_config4g-run.sh.tpl b/omec/omec-control-plane/templates/bin/_config4g-run.sh.tpl
new file mode 100644
index 0000000..b568195
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_config4g-run.sh.tpl
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+set -xe
+
+{{- if .Values.config.coreDump.enabled }}
+cp /free5gc/webconsole/webconsole /tmp/coredump/
+{{- end }}
+
+cd /free5gc
+
+cat config/webuicfg.conf
+
+./webconsole/webconsole -webuicfg config/webuicfg.conf
diff --git a/omec/omec-control-plane/templates/configmap-config4g.yaml b/omec/omec-control-plane/templates/configmap-config4g.yaml
new file mode 100644
index 0000000..7a0b722
--- /dev/null
+++ b/omec/omec-control-plane/templates/configmap-config4g.yaml
@@ -0,0 +1,40 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.config4g.deploy }}
+
+{{- if not .Values.config.useExistingConfigMap -}}
+{{- $config4gcfg := index .Values.config.config4g.cfgFiles "webuicfg.conf" }}
+{{- $config := index $config4gcfg "configuration" }}
+
+{{- if not (hasKey $config4gcfg "logger") -}}
+{{- $_ := .Values.config.logger | set $config4gcfg "logger" -}}
+{{- end }}
+
+{{- if not (hasKey $config "managedByConfigPod") -}}
+{{- $_ := .Values.config.managedByConfigPod | set $config "managedByConfigPod" -}}
+{{- end }}
+
+
+{{- end }}
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: config4g
+  labels:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+  config4g-run.sh: |
+{{ tuple "bin/_config4g-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+{{- if not .Values.config.useExistingConfigMap -}}
+{{- range $key, $value := .Values.config.config4g.cfgFiles }}
+  {{ $key }}: |-
+{{ toYaml $value | indent 4 }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/service-config4g.yaml b/omec/omec-control-plane/templates/service-config4g.yaml
new file mode 100644
index 0000000..ab01c6c
--- /dev/null
+++ b/omec/omec-control-plane/templates/service-config4g.yaml
@@ -0,0 +1,52 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.config4g.deploy }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: config4g
+  labels:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+spec:
+  type: ClusterIP
+  selector:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+  ports:
+  - name: prometheus-exporter
+    port: {{ .Values.config.config4g.prometheus.port }}
+    protocol: TCP
+  - name: urlport-http
+    port: {{ .Values.config.config4g.urlport.port }}
+    protocol: TCP
+{{- if or .Values.config.config4g.urlport.nodePort.enabled .Values.config.config4g.prometheus.nodePort.enabled }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: config4g-external
+  labels:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+spec:
+  type: NodePort
+  selector:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+  ports:
+{{- if .Values.config.config4g.prometheus.nodePort.enabled }}
+  - name: prometheus-exporter
+    port: {{ .Values.config.config4g.prometheus.port }}
+    protocol: TCP
+    nodePort: {{ .Values.config.config4g.prometheus.nodePort.port }}
+{{- end }}
+{{- if .Values.config.config4g.urlport.nodePort.enabled }}
+  - name: urlport-http
+    port: {{ .Values.config.config4g.urlport.port }}
+    protocol: TCP
+    nodePort: {{ .Values.config.config4g.urlport.nodePort.port }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/service-mme.yaml b/omec/omec-control-plane/templates/service-mme.yaml
index 69e8af7..8ae95b9 100644
--- a/omec/omec-control-plane/templates/service-mme.yaml
+++ b/omec/omec-control-plane/templates/service-mme.yaml
@@ -32,6 +32,12 @@
     - name: prometheus-exporter
       port: {{ .Values.config.mme.prometheus.port }}
       protocol: TCP
+    - name: mme-app-config
+      port: 8080
+      protocol: TCP
+    - name: mme-s1ap-config
+      port: 8081
+      protocol: TCP
 ---
 apiVersion: v1
 kind: Service
diff --git a/omec/omec-control-plane/templates/statefulset-config4g.yaml b/omec/omec-control-plane/templates/statefulset-config4g.yaml
new file mode 100644
index 0000000..2565d7b
--- /dev/null
+++ b/omec/omec-control-plane/templates/statefulset-config4g.yaml
@@ -0,0 +1,81 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.config4g.deploy }}
+{{ tuple "config4g" . | include "omec-control-plane.service_account" }}
+---
+apiVersion: apps/v1
+kind: StatefulSet 
+metadata:
+  name: config4g
+  labels:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+spec:
+  replicas: 1
+  serviceName: config4g-headless
+  selector:
+    matchLabels:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 6 }}
+  template:
+    metadata:
+      labels:
+{{ tuple "config4g" . | include "omec-control-plane.metadata_labels" | indent 8 }}
+    {{- with .Values.config.config4g.podAnnotations }}
+      annotations:
+        {{- toYaml . | nindent 8 }}
+    {{- end }}
+    spec:
+      serviceAccountName: config4g
+    {{- if hasKey .Values.images "pullSecrets" }}
+      imagePullSecrets:
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
+    {{- end }}
+      containers:
+      - name: config-4g
+        image: {{ .Values.images.tags.config4g }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+      {{- if .Values.config.coreDump.enabled }}
+        securityContext:
+          runAsUser: 0
+      {{- end }}
+        stdin: true
+        tty: true
+        command: ["/free5gc/script/config4g-run.sh"]
+        env:
+        - name: CONFIGPOD_DEPLOYMENT 
+          value: "4G"
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.config4g | indent 10 }}
+      {{- end }}
+        volumeMounts:
+        - name: run-script
+          mountPath: /free5gc/script/config4g-run.sh
+          subPath: config4g-run.sh
+        - name: nf-config
+          mountPath: /free5gc/config
+      {{- if .Values.config.coreDump.enabled }}
+        - name: coredump
+          mountPath: /tmp/coredump
+      {{- end }}
+      volumes:
+      - name: run-script
+        configMap:
+          name: config4g
+          defaultMode: 493
+      - name: nf-config
+        configMap:
+          name: config4g
+          defaultMode: 493
+    {{- if .Values.config.coreDump.enabled }}
+      - name: host-rootfs
+        hostPath:
+          path: /
+      - name: coredump
+        hostPath:
+          path: {{ .Values.config.coreDump.path }}
+    {{- end }}
+{{- end }}
diff --git a/omec/omec-control-plane/values.yaml b/omec/omec-control-plane/values.yaml
index 2f9cb0c..74e2aa6 100644
--- a/omec/omec-control-plane/values.yaml
+++ b/omec/omec-control-plane/values.yaml
@@ -14,6 +14,7 @@
     pcrf: "registry.aetherproject.org/proxy/omecproject/c3po-pcrf:pcrf-7824e6e"
     pcrfdb: "registry.aetherproject.org/proxy/omecproject/c3po-pcrfdb:pcrf-7824e6e"
     depCheck: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
+    config4g: "registry.aetherproject.org/omecproject/5gc-webui:onf-release3.0.5-latest"
   pullPolicy: IfNotPresent
   # Secrets must be manually created in the namespace.
   pullSecrets:
@@ -33,6 +34,9 @@
   spgwc:
     label: omec-cp
     value: enabled
+  config4g:
+    label: omec-cp
+    value: enabled
 
 resources:
   enabled: true
@@ -66,6 +70,13 @@
     limits:
       cpu: 2
       memory: 5Gi
+  config4g:
+    requests:
+      cpu: 1
+      memory: 1Gi
+    limits:
+      cpu: 1
+      memory: 1Gi
 
 cassandra:
   deploy: true
@@ -97,6 +108,51 @@
     enabled: true
     path: /tmp/coredump
   useExistingConfigMap: false
+  logger:
+    WEBUI:
+      debugLevel: info
+      ReportCaller: false
+  config4g:
+    deploy: false
+    podAnnotations:
+      field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9089,"schema":"HTTP"}]'
+    prometheus:
+      port: 9089
+      nodePort:
+        enabled: false
+        port: 30084
+    urlport:
+      port: 5000
+      nodePort:
+        enabled: false
+        port: 35000
+    ingress:
+      enabled: false
+      hostname: free5gc.local
+      path: /
+      pathType: Prefix
+    cfgFiles:
+      webuicfg.conf:
+        info:
+          version: 1.0.0
+          description: WebUI initial local configuration
+        configuration:
+          endpoints:
+            - type: spgw
+              configPushUrl: "http://spgwc:8080/v1/config"
+              configCheckUrl: "http://spgwc:8080/v1/config-check"
+            #- type: mmeapp
+            #  configPushUrl: "http://mme-app-config:8080/v1/config/slice"
+            #  configCheckUrl: "http://mme-app-config:8080/v1/config-check"
+            #- type: mmes1ap
+            #  configPushUrl: "http://mme-s1ap-config:8080/v1/config/slice"
+            #  configCheckUrl: "http://mme-s1ap-config:8080/v1/config-check"
+            - type: hss
+              configPushUrl: "http://hss:8080/v2/config/imsis"
+              configCheckUrl: "http://hss:8080/v2/config-check"
+            #- type: pcrf
+            #  configPushUrl: "http://pcrf:8080/v1/config/policies"
+            #  configCheckUrl: "http://pcrf:8080/v1/config-check"
   pcrf:
     deploy: true
     podAnnotations: