AETHER-1260 Better support of helm-kustomize for omec-control-plane chart

Change-Id: I24c22cbacca60e3b6c5c3bca7ec76c9c987c2b56
diff --git a/omec/omec-control-plane/Chart.yaml b/omec/omec-control-plane/Chart.yaml
index 9bc06d3..be57891 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.8
+version: 0.6.9
diff --git a/omec/omec-control-plane/templates/configmap-hss.yaml b/omec/omec-control-plane/templates/configmap-hss.yaml
index 8d94491..029a8b6 100644
--- a/omec/omec-control-plane/templates/configmap-hss.yaml
+++ b/omec/omec-control-plane/templates/configmap-hss.yaml
@@ -9,6 +9,7 @@
 */}}
 
 {{- if .Values.config.hss.deploy }}
+{{- if not .Values.config.useExistingConfigMap }}
 {{- $hssJson := index .Values.config.hss.cfgFiles "hss.json" }}
 {{- $hssJsonCommon := index $hssJson "common" }}
 {{- $hssJsonHss := index $hssJson "hss" }}
@@ -100,6 +101,7 @@
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+{{- end }}
 ---
 apiVersion: v1
 kind: ConfigMap
diff --git a/omec/omec-control-plane/templates/configmap-mme.yaml b/omec/omec-control-plane/templates/configmap-mme.yaml
index efbf281..f45f6ed 100644
--- a/omec/omec-control-plane/templates/configmap-mme.yaml
+++ b/omec/omec-control-plane/templates/configmap-mme.yaml
@@ -5,6 +5,7 @@
 */}}
 
 {{- if .Values.config.mme.deploy }}
+{{- if not .Values.config.useExistingConfigMap }}
 {{- $configJson := index .Values.config.mme.cfgFiles "config.json" }}
 {{- $configJsonMme := index $configJson "mme" }}
 {{- $configJsonS6a := index $configJson "s6a" }}
@@ -37,7 +38,7 @@
     #Port = 3868;
     #SecPort = 3869;
 
-    ConnectPeer = {{ index $configJsonS6a "host" | quote }} { No_TLS; port = 3868; };
+    ConnectPeer = {{ tuple "hss" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }} { No_TLS; port = 3868; };
 
     LoadExtension = "/usr/local/lib/freeDiameter/dict_3gpp2_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_draftload_avps.fdx";
@@ -85,6 +86,7 @@
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+{{- end }}
 ---
 apiVersion: v1
 kind: ConfigMap
diff --git a/omec/omec-control-plane/templates/configmap-pcrf.yaml b/omec/omec-control-plane/templates/configmap-pcrf.yaml
index 9400601..dff2095 100644
--- a/omec/omec-control-plane/templates/configmap-pcrf.yaml
+++ b/omec/omec-control-plane/templates/configmap-pcrf.yaml
@@ -9,6 +9,7 @@
 */}}
 
 {{- if .Values.config.pcrf.deploy }}
+{{- if not .Values.config.useExistingConfigMap }}
 {{- $pcrfJson := index .Values.config.pcrf.cfgFiles "pcrf.json" }}
 {{- $pcrfJsonCommon := index $pcrfJson "common" }}
 {{- $pcrfJsonHss := index $pcrfJson "pcrf" }}
@@ -100,6 +101,7 @@
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+{{- end }}
 ---
 apiVersion: v1
 kind: ConfigMap
diff --git a/omec/omec-control-plane/templates/configmap-spgwc.yaml b/omec/omec-control-plane/templates/configmap-spgwc.yaml
index ab73c62..645bfff 100644
--- a/omec/omec-control-plane/templates/configmap-spgwc.yaml
+++ b/omec/omec-control-plane/templates/configmap-spgwc.yaml
@@ -5,6 +5,7 @@
 */}}
 
 {{- if .Values.config.spgwc.deploy }}
+{{- if not .Values.config.useExistingConfigMap }}
 {{- $cpJson := index .Values.config.spgwc.jsonCfgFiles "cp.json" }}
 {{- $global := index $cpJson "global" }}
 {{- $configJson := index .Values.config.spgwc.jsonCfgFiles "config.json" }}
@@ -89,7 +90,7 @@
     #Port = 3868;
     #SecPort = 3869;
 
-    ConnectPeer = {{ index $configJsonGx "host" | quote }} { No_TLS; port = 3868; };
+    ConnectPeer = {{ tuple "pcrf" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }} { No_TLS; port = 3868; };
 
     LoadExtension = "/usr/local/lib/freeDiameter/dict_3gpp2_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_draftload_avps.fdx";
@@ -134,6 +135,7 @@
   {{ $key }}: |-
 {{ toPrettyJson $value | indent 4 }}
 {{- end }}
+{{- end }}
 ---
 apiVersion: v1
 kind: ConfigMap
diff --git a/omec/omec-control-plane/templates/secret-registry.yaml b/omec/omec-control-plane/templates/secret-registry.yaml
deleted file mode 100644
index 1502049..0000000
--- a/omec/omec-control-plane/templates/secret-registry.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-{{/*
-# Copyright 2020-present Open Networking Foundation
-
-# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
-*/}}
-
-{{- if .Values.images.credentials }}
----
-kind: Secret
-apiVersion: v1
-metadata:
-  name: {{ .Release.Name }}.registry
-  labels:
-    release: {{ .Release.Name }}
-type: kubernetes.io/dockerconfigjson
-data:
-  .dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` (.Values.images.credentials.registry | quote) (printf "%s:%s" .Values.images.credentials.username .Values.images.credentials.password | b64enc) | b64enc | quote }}
-{{- end }}
diff --git a/omec/omec-control-plane/templates/statefulset-hss.yaml b/omec/omec-control-plane/templates/statefulset-hss.yaml
index 11ce47c..a69b4ac 100644
--- a/omec/omec-control-plane/templates/statefulset-hss.yaml
+++ b/omec/omec-control-plane/templates/statefulset-hss.yaml
@@ -37,9 +37,9 @@
         {{ .Values.nodeSelectors.hss.label }}: {{ .Values.nodeSelectors.hss.value }}
     {{- end }}
       serviceAccountName: hss
-    {{- if .Values.images.credentials }}
+    {{- if hasKey .Values.images "pullSecrets" }}
       imagePullSecrets:
-        - name: {{ .Release.Name }}.registry
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
     {{- end }}
       initContainers:
       - name: hss-bootstrap
diff --git a/omec/omec-control-plane/templates/statefulset-mme.yaml b/omec/omec-control-plane/templates/statefulset-mme.yaml
index c0b6e82..0a47593 100644
--- a/omec/omec-control-plane/templates/statefulset-mme.yaml
+++ b/omec/omec-control-plane/templates/statefulset-mme.yaml
@@ -33,9 +33,9 @@
         {{ .Values.nodeSelectors.mme.label }}: {{ .Values.nodeSelectors.mme.value }}
     {{- end }}
       serviceAccountName: mme
-    {{- if .Values.images.credentials }}
+    {{- if hasKey .Values.images "pullSecrets" }}
       imagePullSecrets:
-        - name: {{ .Release.Name }}.registry
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
     {{- end }}
       initContainers:
       - name: mme-load-sctp-module
diff --git a/omec/omec-control-plane/templates/statefulset-pcrf.yaml b/omec/omec-control-plane/templates/statefulset-pcrf.yaml
index 45af96b..a7eb327 100644
--- a/omec/omec-control-plane/templates/statefulset-pcrf.yaml
+++ b/omec/omec-control-plane/templates/statefulset-pcrf.yaml
@@ -32,9 +32,9 @@
       nodeSelector:
         {{ .Values.nodeSelectors.pcrf.label }}: {{ .Values.nodeSelectors.pcrf.value }}
     {{- end }}
-    {{- if .Values.images.credentials }}
+    {{- if hasKey .Values.images "pullSecrets" }}
       imagePullSecrets:
-        - name: {{ .Release.Name }}.registry
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
     {{- end }}
       serviceAccountName: pcrf
       initContainers:
diff --git a/omec/omec-control-plane/templates/statefulset-spgwc.yaml b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
index 897131c..7d2b9b3 100644
--- a/omec/omec-control-plane/templates/statefulset-spgwc.yaml
+++ b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
@@ -33,9 +33,9 @@
         {{ .Values.nodeSelectors.spgwc.label }}: {{ .Values.nodeSelectors.spgwc.value }}
     {{- end }}
       serviceAccountName: spgwc
-    {{- if .Values.images.credentials }}
+    {{- if hasKey .Values.images "pullSecrets" }}
       imagePullSecrets:
-        - name: {{ .Release.Name }}.registry
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
     {{- end }}
     {{- if .Values.config.coreDump.enabled }}
       initContainers:
diff --git a/omec/omec-control-plane/values.yaml b/omec/omec-control-plane/values.yaml
index 1e7396f..2d6a6b8 100644
--- a/omec/omec-control-plane/values.yaml
+++ b/omec/omec-control-plane/values.yaml
@@ -15,11 +15,10 @@
     pcrfdb: omecproject/c3po-pcrfdb:pcrf-latest
     depCheck: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
   pullPolicy: IfNotPresent
-  credentials: {}
-  # If specified, use this credential to access the image
-  #   registry:
-  #   username:
-  #   password:
+  # Optionally specify an array of imagePullSecrets.
+  # Secrets must be manually created in the namespace.
+  #pullSecrets:
+  #  - name: aether.registry
 
 nodeSelectors:
   enabled: false
@@ -98,8 +97,12 @@
   coreDump:
     enabled: true
     path: /tmp/coredump
+  useExistingConfigMap: false
   pcrf:
     deploy: true
+    podAnnotations:
+      fluentbit.io/parser: pcrf
+      field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9089,"schema":"HTTP"}]'
     pcrfdb: cassandra
     gx:
       nodePort:
@@ -183,11 +186,10 @@
                 options:
                   - id: frequency
                     type: integer
-
-
   hss:
     deploy: true
     podAnnotations:
+      fluentbit.io/parser: hss
       field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9089,"schema":"HTTP"}]'
     hssdb: cassandra
     s6a:
@@ -302,10 +304,10 @@
                 options:
                   - id: frequency
                     type: integer
-
   mme:
     deploy: true
     podAnnotations:
+      fluentbit.io/parser: mme
       field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":3081,"schema":"HTTP"}]'
     spgwAddr: spgwc
     s11:
@@ -365,6 +367,7 @@
   spgwc:
     deploy: true
     podAnnotations:
+      fluentbit.io/parser: spgwc
       field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9089,"schema":"HTTP"}]'
     global:
       transmitTimerSec: 2