COMAC-188 Use service domain for HSS and MME diameter peer

Change-Id: Ie1794a4ec65ce0f42303df7c226a0ff6a2e00ec8
diff --git a/omec/omec-control-plane/templates/_helpers.tpl b/omec/omec-control-plane/templates/_helpers.tpl
index a6630f1..223a933 100644
--- a/omec/omec-control-plane/templates/_helpers.tpl
+++ b/omec/omec-control-plane/templates/_helpers.tpl
@@ -37,18 +37,18 @@
 {{- end -}}
 
 {{/*
-Return identity, realm, and hostname of the first pod of the given statefulset.
+Return s6a service for Diameter identity, realm, and hostname for a given application.
 */}}
-{{- define "omec-control-plane.endpoint_lookup" -}}
+{{- define "omec-control-plane.diameter_endpoint" -}}
 {{- $service := index . 0 -}}
 {{- $type := index . 1 -}}
 {{- $context := index . 2 -}}
 {{- if eq $type "identity" -}}
-{{- printf "%s-0.%s.%s.svc.%s" $service $service $context.Release.Namespace "cluster.local" -}}
+{{- printf "%s-s6a.%s.svc.%s" $service $context.Release.Namespace "cluster.local" -}}
 {{- else if eq $type "realm" -}}
-{{- printf "%s.%s.svc.%s" $service $context.Release.Namespace "cluster.local" -}}
+{{- printf "%s.svc.%s" $context.Release.Namespace "cluster.local" -}}
 {{- else if eq $type "host" -}}
-{{- printf "%s-0" $service -}}
+{{- printf "%s-s6a" $service -}}
 {{- end -}}
 {{- end -}}
 
diff --git a/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl b/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl
index e953b61..7895ed3 100644
--- a/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl
@@ -67,8 +67,8 @@
     echo -e "Added mme $id\n"
 }
 
-mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.endpoint_lookup" }}
-mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.endpoint_lookup" }}
+mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" }}
+mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" }}
 
 {{- range .Values.config.hss.bootstrap.users }}
 provision_users \
diff --git a/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl b/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl
index 9782de2..b3d9be1 100644
--- a/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl
@@ -24,7 +24,7 @@
 cat $CONF_DIR/{hss.json,hss.conf}
 
 cd $CONF_DIR
-make_certs.sh {{ tuple "hss" "host" . | include "omec-control-plane.endpoint_lookup" }} {{ tuple "hss" "realm" . | include "omec-control-plane.endpoint_lookup" }}
+make_certs.sh {{ tuple "hss" "host" . | include "omec-control-plane.diameter_endpoint" }} {{ tuple "hss" "realm" . | include "omec-control-plane.diameter_endpoint" }}
 
 cd ..
 hss -j $CONF_DIR/hss.json
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 11d1218..8df3f00 100644
--- a/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
@@ -45,9 +45,9 @@
 cp /opt/mme/config/s6a_fd.conf /opt/mme/config/shared/s6a_fd.conf
 
 # Generate certs
-MME_IDENTITY={{ tuple "mme" "identity" . | include "omec-control-plane.endpoint_lookup" | quote }};
+MME_IDENTITY={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }};
 DIAMETER_HOST=$(echo $MME_IDENTITY | cut -d'.' -f1)
-DIAMETER_REALM={{ tuple "mme" "realm" . | include "omec-control-plane.endpoint_lookup" | quote }};
+DIAMETER_REALM={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" | quote }};
 
 cp /openmme/target/conf/make_certs.sh /opt/mme/config/shared/make_certs.sh
 cd /opt/mme/config/shared
diff --git a/omec/omec-control-plane/templates/configmap-hss.yaml b/omec/omec-control-plane/templates/configmap-hss.yaml
index 76760e0..c831c87 100644
--- a/omec/omec-control-plane/templates/configmap-hss.yaml
+++ b/omec/omec-control-plane/templates/configmap-hss.yaml
@@ -23,10 +23,10 @@
 {{- $hssJsonHss := index $hssJson "hss" }}
 
 {{- if not (hasKey $hssJsonCommon "originhost") -}}
-{{- $_ := tuple "hss" "identity" . | include "omec-control-plane.endpoint_lookup" | set $hssJsonCommon "originhost" -}}
+{{- $_ := tuple "hss" "identity" . | include "omec-control-plane.diameter_endpoint" | set $hssJsonCommon "originhost" -}}
 {{- end }}
 {{- if not (hasKey $hssJsonCommon "originrealm") -}}
-{{- $_ := tuple "hss" "realm" . | include "omec-control-plane.endpoint_lookup" | set $hssJsonCommon "originrealm" -}}
+{{- $_ := tuple "hss" "realm" . | include "omec-control-plane.diameter_endpoint" | set $hssJsonCommon "originrealm" -}}
 {{- end }}
 {{- if not (hasKey $hssJsonHss "casssrv") -}}
 {{- $_ := .Values.cassandra.fullnameOverride | set $hssJsonHss "casssrv" -}}
@@ -47,10 +47,10 @@
     ALLOW_IPSEC {{ .Values.config.hss.acl.ipSec }}
   {{- end }}
   hss.conf: |
-    Identity = {{ tuple "hss" "identity" . | include "omec-control-plane.endpoint_lookup" | quote }};
-    Realm = {{ tuple "hss" "realm" . | include "omec-control-plane.endpoint_lookup" | quote }};
-    TLS_Cred = "/opt/c3po/hss/conf/{{ tuple "hss" "host" . | include "omec-control-plane.endpoint_lookup" }}.cert.pem",
-               "/opt/c3po/hss/conf/{{ tuple "hss" "host" . | include "omec-control-plane.endpoint_lookup" }}.key.pem";
+    Identity = {{ tuple "hss" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }};
+    Realm = {{ tuple "hss" "realm" . | include "omec-control-plane.diameter_endpoint" | quote }};
+    TLS_Cred = "/opt/c3po/hss/conf/{{ tuple "hss" "host" . | include "omec-control-plane.diameter_endpoint" }}.cert.pem",
+               "/opt/c3po/hss/conf/{{ tuple "hss" "host" . | include "omec-control-plane.diameter_endpoint" }}.key.pem";
     TLS_CA = "/opt/c3po/hss/conf/cacert.pem";
     No_SCTP;
     Prefer_TCP;
diff --git a/omec/omec-control-plane/templates/configmap-mme.yaml b/omec/omec-control-plane/templates/configmap-mme.yaml
index 663af63..6ec9576 100644
--- a/omec/omec-control-plane/templates/configmap-mme.yaml
+++ b/omec/omec-control-plane/templates/configmap-mme.yaml
@@ -18,10 +18,10 @@
 {{- $configJsonS6a := index $configJson "s6a" }}
 
 {{- if not (hasKey $configJsonS6a "host") -}}
-{{- $_ := tuple "hss" "identity" . | include "omec-control-plane.endpoint_lookup" | set $configJsonS6a "host" -}}
+{{- $_ := tuple "hss" "identity" . | include "omec-control-plane.diameter_endpoint" | set $configJsonS6a "host" -}}
 {{- end }}
 {{- if not (hasKey $configJsonS6a "realm") -}}
-{{- $_ := tuple "hss" "realm" . | include "omec-control-plane.endpoint_lookup" | set $configJsonS6a "realm" -}}
+{{- $_ := tuple "hss" "realm" . | include "omec-control-plane.diameter_endpoint" | set $configJsonS6a "realm" -}}
 {{- end }}
 ---
 apiVersion: v1
@@ -32,10 +32,10 @@
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 data:
   s6a_fd.conf: |
-    Identity = {{ tuple "mme" "identity" . | include "omec-control-plane.endpoint_lookup" | quote }};
-    Realm = {{ tuple "mme" "realm" . | include "omec-control-plane.endpoint_lookup" | quote }};
-    TLS_Cred = "conf/{{ tuple "mme" "host" . | include "omec-control-plane.endpoint_lookup" }}.cert.pem",
-               "conf/{{ tuple "mme" "host" . | include "omec-control-plane.endpoint_lookup" }}.key.pem";
+    Identity = {{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }};
+    Realm = {{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" | quote }};
+    TLS_Cred = "conf/{{ tuple "mme" "host" . | include "omec-control-plane.diameter_endpoint" }}.cert.pem",
+               "conf/{{ tuple "mme" "host" . | include "omec-control-plane.diameter_endpoint" }}.key.pem";
     TLS_CA = "conf/cacert.pem";
     AppServThreads = 40;
     SCTP_streams = 3;
@@ -44,7 +44,7 @@
     #Port = 3868;
     #SecPort = 3869;
 
-    ConnectPeer = {{ tuple "hss" "identity" . | include "omec-control-plane.endpoint_lookup" | 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";
diff --git a/omec/omec-control-plane/templates/service-hss.yaml b/omec/omec-control-plane/templates/service-hss.yaml
index 849e713..dbfccf5 100644
--- a/omec/omec-control-plane/templates/service-hss.yaml
+++ b/omec/omec-control-plane/templates/service-hss.yaml
@@ -15,21 +15,6 @@
 */}}
 
 ---
-# Additional service for identity
-apiVersion: v1
-kind: Service
-metadata:
-  name: hss
-  labels:
-{{ tuple "hss" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-spec:
-  selector:
-{{ tuple "hss" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  ports:
-  - name: s6a
-    port: 3868
-    protocol: TCP
----
 apiVersion: v1
 kind: Service
 metadata:
diff --git a/omec/omec-control-plane/templates/service-mme.yaml b/omec/omec-control-plane/templates/service-mme.yaml
index 24ddc0f..b8b6a30 100644
--- a/omec/omec-control-plane/templates/service-mme.yaml
+++ b/omec/omec-control-plane/templates/service-mme.yaml
@@ -18,21 +18,6 @@
 {{- $configJsonS11 := index $configJson "s11" }}
 {{- $configJsonS1ap := index $configJson "s1ap" }}
 ---
-# Additional service for identity
-apiVersion: v1
-kind: Service
-metadata:
-  name: mme
-  labels:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-spec:
-  selector:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  ports:
-  - name: s6a
-    port: 3868
-    protocol: TCP
----
 apiVersion: v1
 kind: Service
 metadata:
diff --git a/omec/omec-control-plane/templates/statefulset-hss.yaml b/omec/omec-control-plane/templates/statefulset-hss.yaml
index 53cb687..291205e 100644
--- a/omec/omec-control-plane/templates/statefulset-hss.yaml
+++ b/omec/omec-control-plane/templates/statefulset-hss.yaml
@@ -31,7 +31,6 @@
   selector:
     matchLabels:
 {{ tuple "hss" . | include "omec-control-plane.metadata_labels" | indent 6 }}
-  serviceName: hss
   template:
     metadata:
       labels:
diff --git a/omec/omec-control-plane/templates/statefulset-mme.yaml b/omec/omec-control-plane/templates/statefulset-mme.yaml
index f0e7290..fbaf094 100644
--- a/omec/omec-control-plane/templates/statefulset-mme.yaml
+++ b/omec/omec-control-plane/templates/statefulset-mme.yaml
@@ -27,7 +27,6 @@
   selector:
     matchLabels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 6 }}
-  serviceName: mme
   template:
     metadata:
       labels: