Remove namespace and assign in Jenkinsfile

Change-Id: I11a2a636375000fc18b00e26d10afe5b04f4ebc3
diff --git a/mcord/mcord-control-plane/templates/_helpers.tpl b/mcord/mcord-control-plane/templates/_helpers.tpl
index bb59df4..ec4bb37 100644
--- a/mcord/mcord-control-plane/templates/_helpers.tpl
+++ b/mcord/mcord-control-plane/templates/_helpers.tpl
@@ -31,10 +31,10 @@
 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
 {{- else -}}
 {{- $name := default .Chart.Name .Values.nameOverride -}}
-{{- if contains $name .Values.namespace -}}
-{{- .Values.namespace | trunc 63 | trimSuffix "-" -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
 {{- else -}}
-{{- printf "%s-%s" .Values.namespace $name | trunc 63 | trimSuffix "-" -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
 {{- end -}}
 {{- end -}}
 {{- end -}}
diff --git a/mcord/mcord-control-plane/templates/cassandra.yaml b/mcord/mcord-control-plane/templates/cassandra.yaml
index 56688f8..d20ed06 100644
--- a/mcord/mcord-control-plane/templates/cassandra.yaml
+++ b/mcord/mcord-control-plane/templates/cassandra.yaml
@@ -17,7 +17,6 @@
 apiVersion: v1
 kind: Service
 metadata:
-  namespace: {{ .Values.namespace }}
   labels:
     app: cassandra
   name: cassandra
@@ -31,7 +30,6 @@
 apiVersion: "apps/v1"
 kind: StatefulSet
 metadata:
-  namespace: {{ .Values.namespace }}
   name: cassandra
   labels:
      app: cassandra
@@ -43,7 +41,6 @@
       app: cassandra
   template:
     metadata:
-      namespace: {{ .Values.namespace }}
       labels:
         app: cassandra
     spec:
@@ -62,7 +59,7 @@
           - name: HEAP_NEWSIZE
             value: 100M
           - name: CASSANDRA_SEEDS
-            value: "cassandra-0.cassandra.{{ .Values.namespace }}.svc.cluster.local"
+            value: "cassandra-0.cassandra.{{ .Release.Name }}.svc.cluster.local"
           - name: CASSANDRA_CLUSTER_NAME
             value: "HSS Cluster"
           - name: CASSANDRA_RPC_ADDRESS
diff --git a/mcord/mcord-control-plane/templates/cm.yaml b/mcord/mcord-control-plane/templates/cm.yaml
index 26b226e..da5f864 100644
--- a/mcord/mcord-control-plane/templates/cm.yaml
+++ b/mcord/mcord-control-plane/templates/cm.yaml
@@ -16,7 +16,6 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  namespace: {{ .Values.namespace }}
   name: ngiccp-config
 data:
   adc_rules.cfg: |
@@ -133,8 +132,8 @@
     APP_ARGS="${S1U} ${SGI} ${WORKERS} ${MISC} ${SPGW_CFG}"
   interface.cfg: |
     [0]
-    dp_comm_ip = ngic-dp-0.ngic-dp.{{ .Values.namespace }}.cluster.global
-    dp_comm_port = 20
+    dp_comm_ip = {{ .Values.dataplane_hostname }}
+    dp_comm_port = {{ .Values.dataplane_port }}
     cp_comm_ip = 127.0.0.1
     cp_comm_port = 21
   meter_profile.cfg: |
@@ -441,7 +440,6 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  namespace: {{ .Values.namespace }}
   name: cassandra
 data:
   cassandra-rackdc.properties: |
@@ -452,7 +450,6 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  namespace: {{ .Values.namespace }}
   name: hss
 data:
   acl.conf: |
@@ -695,7 +692,6 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  namespace: {{ .Values.namespace }}
   name: mme
 data:
   launch.sh: |
diff --git a/mcord/mcord-control-plane/templates/cp.yaml b/mcord/mcord-control-plane/templates/cp.yaml
index dc6545f..ad417d8 100644
--- a/mcord/mcord-control-plane/templates/cp.yaml
+++ b/mcord/mcord-control-plane/templates/cp.yaml
@@ -17,7 +17,6 @@
 apiVersion: v1
 kind: Service
 metadata:
-  namespace: {{ .Values.namespace }}
   name: ngic-cp
 spec:
   selector:
@@ -34,7 +33,6 @@
 apiVersion: apps/v1
 kind: StatefulSet
 metadata:
-  namespace: {{ .Values.namespace }}
   name: ngic-cp
   labels:
     app: ngic-cp
@@ -46,7 +44,6 @@
   serviceName: "ngic-cp"
   template:
     metadata:
-      namespace: {{ .Values.namespace }}
       labels:
         app: ngic-cp
     spec:
@@ -71,7 +68,7 @@
         tty: true
         env:
         - name: MME_S11_IP
-          value: mme-0.mme.{{ .Values.namespace }}.local
+          value: mme
         #- name: SGW_S1U_IP  # for now,this will be in our own pod
         #  value: "5.5.5.5"
         - name: APN
diff --git a/mcord/mcord-control-plane/templates/hss.yaml b/mcord/mcord-control-plane/templates/hss.yaml
index 48ccdfc..6c7c9e4 100644
--- a/mcord/mcord-control-plane/templates/hss.yaml
+++ b/mcord/mcord-control-plane/templates/hss.yaml
@@ -17,7 +17,6 @@
 apiVersion: v1
 kind: Service
 metadata:
-  namespace: {{ .Values.namespace }}
   name: hss
 spec:
   selector:
@@ -31,7 +30,6 @@
 apiVersion: apps/v1
 kind: StatefulSet
 metadata:
-  namespace: {{ .Values.namespace }}
   name: hss
   labels:
     app: hss
@@ -43,7 +41,6 @@
   serviceName: "hss"
   template:
     metadata:
-      namespace: {{ .Values.namespace }}
       labels:
         app: hss
     spec:
@@ -56,10 +53,10 @@
         - until nslookup cassandra; do echo waiting for cassandra; sleep 2; done;
           sleep 5;
           cqlsh --file /scripts/oai_db.cql cassandra;
-          /scripts/data_provisioning_users.sh 302720100000421 1122334456 apn1 6226194254742F2D67145153602F7C8D 1 cassandra mme-0.mme.{{ .Values.namespace }}.svc.cluster.local mme.{{ .Values.namespace }}.svc.cluster.local;
+          /scripts/data_provisioning_users.sh 302720100000421 1122334456 apn1 6226194254742F2D67145153602F7C8D 1 cassandra mme mme;
           cqlsh -e "use vhss; update users_imsi set opc='D6CAF10C337FD65AC31A18EBACBF5BF9' where imsi='302720100000421';" cassandra;
           cqlsh -e "select imsi,key,opc,sqn from vhss.users_imsi;" cassandra;
-          /scripts/data_provisioning_mme.sh 1 19136246000 mme-0.mme.{{ .Values.namespace }}.svc.cluster.local mme.{{ .Values.namespace }}.svc.cluster.local 1 cassandra;
+          /scripts/data_provisioning_mme.sh 1 19136246000 mme mme 1 cassandra;
           /scripts/data_provisioning_mme.sh 1 19136246000 smsrouter.test3gpp.net test3gpp.net 0  cassandra;
       containers:
       - name: hss
@@ -69,7 +66,7 @@
           - name: CASSANDRA_ADDR
             value: cassandra
           - name: MME_ADDR
-            value: mme-0.mme.{{ .Values.namespace }}.svc.cluster.local
+            value: mme
         #command: [ "sleep", "3600"]
         resources:
           limits:
diff --git a/mcord/mcord-control-plane/templates/mme.yaml b/mcord/mcord-control-plane/templates/mme.yaml
index 7b85e55..2f2ebd4 100644
--- a/mcord/mcord-control-plane/templates/mme.yaml
+++ b/mcord/mcord-control-plane/templates/mme.yaml
@@ -17,7 +17,6 @@
 apiVersion: v1
 kind: Service
 metadata:
-  namespace: {{ .Values.namespace }}
   name: mme
 spec:
   selector:
@@ -37,7 +36,6 @@
 apiVersion: apps/v1
 kind: StatefulSet
 metadata:
-  namespace: {{ .Values.namespace }}
   name: mme
   labels:
     app: mme
@@ -49,7 +47,6 @@
   serviceName: "mme"
   template:
     metadata:
-      namespace: {{ .Values.namespace }}
       labels:
         app: mme
     spec:
@@ -65,7 +62,7 @@
               - NET_ADMIN
         args:
         - iptables -A OUTPUT -p sctp --sport {{ .Values.mme.ports.s1ap }} --chunk-types any ABORT -j DROP;
-          until nslookup hss-0.hss.{{ .Values.namespace }}.svc.cluster.local;
+          until nslookup hss;
           do echo waiting for hss; sleep 2; done;
       containers:
       - name: mme
@@ -73,7 +70,7 @@
         imagePullPolicy: Always
         env:
           - name: SGW_S11_IP
-            value: ngic-0.ngic-cp.{{ .Values.namespace }}.svc.cluster.local
+            value: ngic-cp
           - name: MME_ETH0_IP
             valueFrom:
               fieldRef:
@@ -83,11 +80,11 @@
           - name: ENB_S1AP_PORT
             value: "{{ .Values.mme.ports.s1ap }}"   #ng4t uses 32767
           - name: CONNECT_PEER
-            value: hss-0.hss.{{ .Values.namespace }}.svc.cluster.local
+            value: hss
           - name: VAR_HSS_REALM
-            value: hss.{{ .Values.namespace }}.svc.cluster.local
+            value: hss
           - name: HSS_S6A_IP
-            value: hss-0.hss.{{ .Values.namespace }}.svc.cluster.local
+            value: hss
           - name: HSS_PORT
             value: "{{ .Values.mme.ports.s6a }}"
         stdin: true
diff --git a/mcord/mcord-control-plane/templates/namespace.yaml b/mcord/mcord-control-plane/templates/namespace.yaml
deleted file mode 100644
index a135721..0000000
--- a/mcord/mcord-control-plane/templates/namespace.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
----
-apiVersion: v1
-kind: Namespace
-metadata:
-  name: {{ .Values.namespace }}
diff --git a/mcord/mcord-control-plane/values.yaml b/mcord/mcord-control-plane/values.yaml
index 8cbc0aa..3e45d29 100644
--- a/mcord/mcord-control-plane/values.yaml
+++ b/mcord/mcord-control-plane/values.yaml
@@ -17,6 +17,9 @@
 # This is a YAML-formatted file.
 # Declare variables to be passed into your templates.
 
+dataplane_hostname: "ngic-dp"
+dataplane_port: 20
+
 hss:
   # TODO: init UE's IMEI to DB?
   images:
diff --git a/mcord/mcord-data-plane/templates/_helpers.tpl b/mcord/mcord-data-plane/templates/_helpers.tpl
index 6eb0fdf..06c5286 100644
--- a/mcord/mcord-data-plane/templates/_helpers.tpl
+++ b/mcord/mcord-data-plane/templates/_helpers.tpl
@@ -31,10 +31,10 @@
 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
 {{- else -}}
 {{- $name := default .Chart.Name .Values.nameOverride -}}
-{{- if contains $name .Values.namespace -}}
-{{- .Values.namespace | trunc 63 | trimSuffix "-" -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
 {{- else -}}
-{{- printf "%s-%s" .Values.namespace $name | trunc 63 | trimSuffix "-" -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
 {{- end -}}
 {{- end -}}
 {{- end -}}
diff --git a/mcord/mcord-data-plane/templates/cm.yaml b/mcord/mcord-data-plane/templates/cm.yaml
index 37687d9..fe1ce19 100644
--- a/mcord/mcord-data-plane/templates/cm.yaml
+++ b/mcord/mcord-data-plane/templates/cm.yaml
@@ -16,7 +16,6 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  namespace: {{ .Values.namespace }}
   name: ngicdp-config
 data:
   adc_rules.cfg: |
@@ -135,8 +134,8 @@
     [0]
     dp_comm_ip =  127.0.0.1
     dp_comm_port = 20
-    cp_comm_ip = ngic-cp-0.ngic-cp.{{ .Values.namespace }}.cluster.global
-    cp_comm_port = 21
+    cp_comm_ip = {{ .Values.controlplane_hostname }}
+    cp_comm_port = {{ .Values.controlplane_port }}
   meter_profile.cfg: |
     [GLOBAL]
     NUM_OF_IDX = 7
diff --git a/mcord/mcord-data-plane/templates/dp.yaml b/mcord/mcord-data-plane/templates/dp.yaml
index f7da922..a55bb52 100644
--- a/mcord/mcord-data-plane/templates/dp.yaml
+++ b/mcord/mcord-data-plane/templates/dp.yaml
@@ -17,7 +17,6 @@
 apiVersion: v1
 kind: Service
 metadata:
-  namespace: {{ .Values.namespace }}
   name: ngic-dp
 spec:
   selector:
@@ -31,7 +30,6 @@
 apiVersion: apps/v1
 kind: StatefulSet
 metadata:
-  namespace: {{ .Values.namespace }}
   name: ngic-dp
   labels:
     app: ngic-dp
@@ -43,7 +41,6 @@
   serviceName: "ngic-dp"
   template:
     metadata:
-      namespace: {{ .Values.namespace }}
       labels:
         app: ngic-dp
       annotations:
diff --git a/mcord/mcord-data-plane/values.yaml b/mcord/mcord-data-plane/values.yaml
index 80c4852..b1626cd 100644
--- a/mcord/mcord-data-plane/values.yaml
+++ b/mcord/mcord-data-plane/values.yaml
@@ -17,6 +17,9 @@
 # This is a YAML-formatted file.
 # Declare variables to be passed into your templates.
 
+controlplane_hostname: "ngic-cp"
+controlplane_port: 21
+
 ngic_dp:
   images:
     init: "ngick8stesting/c3po-mmeinit"