COMAC-167,COMAC-169,COMAC-126 Refactor SPGWC and MME

- Split SPGWC manifest to multiple files by resource type
- Reconfigure and restart SPGWC when MME pod IP changes
- Add ability to enable node port for S1U and S11 interfaces
- Remove hard-coded configurations
- Reorganize values

Change-Id: Id890d351873922fccd51282825fd35794cfdd917
diff --git a/omec/omec-control-plane/templates/_helpers.tpl b/omec/omec-control-plane/templates/_helpers.tpl
index 91aa5b6..a6630f1 100644
--- a/omec/omec-control-plane/templates/_helpers.tpl
+++ b/omec/omec-control-plane/templates/_helpers.tpl
@@ -51,3 +51,62 @@
 {{- printf "%s-0" $service -}}
 {{- end -}}
 {{- end -}}
+
+{{/*
+Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
+*/}}
+{{- define "omec-control-plane.service_account" -}}
+{{- $context := index . 1 -}}
+{{- $saName := index . 0 -}}
+{{- $saNamespace := $context.Release.Namespace }}
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: {{ $saName }}
+  namespace: {{ $saNamespace }}
+  labels:
+{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
+---
+apiVersion: rbac.authorization.k8s.io/v1beta1
+kind: RoleBinding
+metadata:
+  name: {{ $saName }}
+  namespace: {{ $saNamespace }}
+  labels:
+{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: Role
+  name: {{ $saName }}
+subjects:
+  - kind: ServiceAccount
+    name: {{ $saName }}
+    namespace: {{ $saNamespace }}
+---
+apiVersion: rbac.authorization.k8s.io/v1beta1
+kind: Role
+metadata:
+  name: {{ $saName }}
+  namespace: {{ $saNamespace }}
+  labels:
+{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
+rules:
+  - apiGroups:
+      - ""
+      - extensions
+      - batch
+      - apps
+    verbs:
+      - get
+      - list
+      - patch
+    resources:
+      - statefulsets
+      - daemonsets
+      - jobs
+      - pods
+      - services
+      - endpoints
+      - configmaps
+{{- end -}}
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 0b2e163..11d1218 100644
--- a/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
@@ -20,13 +20,14 @@
 cd /opt/mme/config/shared
 
 # Set local IP address for s1ap and s11 networks to the config
-jq --arg MME_LOCAL_IP "$MME_LOCAL_IP" '.mme.ip_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
-jq --arg MME_LOCAL_IP "$MME_LOCAL_IP" '.s1ap.s1ap_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
-jq --arg MME_LOCAL_IP "$MME_LOCAL_IP" '.s11.egtp_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
+jq --arg MME_LOCAL_IP "$POD_IP" '.mme.ip_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
+jq --arg MME_LOCAL_IP "$POD_IP" '.s1ap.s1ap_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
+jq --arg MME_LOCAL_IP "$POD_IP" '.s11.egtp_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
 
-# Set SPGW-C address to the config
-SPGWC_POD={{ tuple "spgwc" "identity" . | include "omec-control-plane.endpoint_lookup" | quote }}
-SPGWC_ADDR=$(dig +short $SPGWC_POD)
+# Set SPGWC address to the config
+# We need to convert service domain name to actual IP address
+# because mme apps does not take domain address - should be fixed in openmme
+SPGWC_ADDR=$(dig +short +search {{ .Values.config.mme.spgwAddr }})
 jq --arg SPGWC_ADDR "$SPGWC_ADDR" '.s11.sgw_addr //= $SPGWC_ADDR' config.json > config.tmp && mv config.tmp config.json
 jq --arg SPGWC_ADDR "$SPGWC_ADDR" '.s11.pgw_addr //= $SPGWC_ADDR' config.json > config.tmp && mv config.tmp config.json
 
diff --git a/omec/omec-control-plane/templates/bin/_mme-ip.sh.tpl b/omec/omec-control-plane/templates/bin/_mme-ip.sh.tpl
new file mode 100644
index 0000000..92d8a8c
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_mme-ip.sh.tpl
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Copyright 2019-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.
+
+set -x
+
+# Check if mme IP has been changed
+kubectl get cm -n $NAMESPACE -o json mme-ip > mme-ip.json
+mme_ip=$(jq '.data.IP' mme-ip.json)
+if [ $mme_ip != null ] && [ $mme_ip = \"$POD_IP\" ]; then
+    return
+fi
+
+# Update mme IP if it has been changed
+cat <<EOF >patch.json
+{"data": {"IP": "$POD_IP"}}
+EOF
+kubectl patch -n $NAMESPACE configmap mme-ip --patch "$(cat patch.json)"
+
+# Update and restart SPGWC if it is deployed
+kubectl get po -n $NAMESPACE --selector app=spgwc | grep Running -q
+if [ $? -eq 0 ]; then
+    kubectl rollout restart -n $NAMESPACE statefulset/spgwc
+fi
diff --git a/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
new file mode 100644
index 0000000..d08c7b0
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Copyright 2019-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.
+
+set -xe
+
+mkdir -p /opt/cp/config
+cd /opt/cp/config
+cp /etc/cp/config/{adc_rules.cfg,cp_config.cfg,interface.cfg,meter_profile.cfg,pcc_rules.cfg,sdf_rules.cfg} .
+
+sed -i "s/CP_ADDR/$POD_IP/g" interface.cfg
+
+. cp_config.cfg
+ngic_controlplane $EAL_ARGS -- $APP_ARGS
diff --git a/omec/omec-control-plane/templates/configmap-mme-ip.yaml b/omec/omec-control-plane/templates/configmap-mme-ip.yaml
new file mode 100644
index 0000000..4ddc2fc
--- /dev/null
+++ b/omec/omec-control-plane/templates/configmap-mme-ip.yaml
@@ -0,0 +1,27 @@
+{{/*
+Copyright 2019-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: ConfigMap
+metadata:
+  name: mme-ip
+  labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+{{- if hasKey .Values.config.spgwc "mmeAddr" }}
+  IP: {{ .Values.config.spgwc.mmeAddr }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-mme.yaml b/omec/omec-control-plane/templates/configmap-mme.yaml
index 6b33a51..7ca3852 100644
--- a/omec/omec-control-plane/templates/configmap-mme.yaml
+++ b/omec/omec-control-plane/templates/configmap-mme.yaml
@@ -14,11 +14,11 @@
 limitations under the License.
 */}}
 
-{{- if not (hasKey .Values.config.mme.s6a "host") -}}
-{{- $_ := tuple "hss" "identity" . | include "omec-control-plane.endpoint_lookup" | set .Values.config.mme.s6a "host" -}}
+{{- if not (hasKey .Values.config.mme.appConfig.s6a "host") -}}
+{{- $_ := tuple "hss" "identity" . | include "omec-control-plane.endpoint_lookup" | set .Values.config.mme.appConfig.s6a "host" -}}
 {{- end }}
-{{- if not (hasKey .Values.config.mme.s6a "realm") -}}
-{{- $_ := tuple "hss" "realm" . | include "omec-control-plane.endpoint_lookup" | set .Values.config.mme.s6a "realm" -}}
+{{- if not (hasKey .Values.config.mme.appConfig.s6a "realm") -}}
+{{- $_ := tuple "hss" "realm" . | include "omec-control-plane.endpoint_lookup" | set .Values.config.mme.appConfig.s6a "realm" -}}
 {{- end }}
 ---
 apiVersion: v1
@@ -28,9 +28,8 @@
   labels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 data:
-  config.json: {{ toJson .Values.config.mme | quote }}
+  config.json: {{ toJson .Values.config.mme.appConfig | quote }}
   s6a_fd.conf: |
-    # -------- Test configuration ---------
     AppServThreads = 40;
     SCTP_streams = 3;
     NoRelay;
@@ -50,9 +49,6 @@
     TLS_CA = "conf/cacert.pem";
 
     LoadExtension = "/usr/local/lib/freeDiameter/dict_3gpp2_avps.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_CreditControl.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_base_rfc6733.fdx";
-    ###
     LoadExtension = "/usr/local/lib/freeDiameter/dict_draftload_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_etsi283034_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc4004_avps.fdx";
@@ -63,7 +59,6 @@
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5580_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5777_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc5778_avps.fdx";
-    ###
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6734_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc6942_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_rfc7155_avps.fdx";
@@ -90,25 +85,16 @@
     LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29368_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_ts29468_avps.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_ts32299_avps.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_CxDx.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Gx.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_NAS.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Rf.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Ro.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Rx.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6as6d.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6c.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_S6mS6n.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_S6t.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_S9.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_SGd.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_SLh.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Sd.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Sh.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_T4.fdx";
     LoadExtension = "/usr/local/lib/freeDiameter/dict_T6aT6bT7.fdx";
-    #LoadExtension = "/usr/local/lib/freeDiameter/dict_Tsp.fdx";
   mme-init.sh: |
 {{ tuple "bin/_mme-init.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
-  mme-run.sh : |
+  mme-run.sh: |
 {{ tuple "bin/_mme-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+{{- if not (hasKey .Values.config.spgwc "mmeAddr") }}
+  mme-ip.sh: |
+{{ tuple "bin/_mme-ip.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/configmap-spgwc.yaml b/omec/omec-control-plane/templates/configmap-spgwc.yaml
new file mode 100644
index 0000000..a331c91
--- /dev/null
+++ b/omec/omec-control-plane/templates/configmap-spgwc.yaml
@@ -0,0 +1,49 @@
+{{/*
+Copyright 2019-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: ConfigMap
+metadata:
+  name: spgwc
+  labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+data:
+  cp_config.cfg: |
+    if [ ! -d "/dev/hugepages" ]; then
+        MEMORY="--no-huge -m $((MEM_LIMIT-1024))"
+    fi
+    CORES="-c $(taskset -p $$ | awk '{print $NF}')"
+    EAL_ARGS="${CORES} ${MEMORY} --no-pci"
+
+    MGMT_INFO="-s ${POD_IP} -m ${MME_ADDR} -w {{ .Values.config.spgwc.s1uAddr }}"
+    APN_INFO="-i {{ .Values.config.spgwc.ueIpPool.ip }} -p {{ .Values.config.spgwc.ueIpPool.mask }} -a {{ .Values.config.spgwc.apn }}"
+    MISC="-l 2"
+    SPGW_CFG="-d 03"
+
+    APP_ARGS="${MGMT_INFO} ${APN_INFO} ${MISC} ${SPGW_CFG}"
+  interface.cfg: |
+    [0]
+    dp_comm_ip = {{ .Values.config.spgwc.dpComm.addr }}
+    dp_comm_port = {{ .Values.config.spgwc.dpComm.port }}
+    cp_comm_ip = CP_ADDR
+    cp_comm_port = 21
+  spgwc-run.sh: |
+{{ tuple "bin/_spgwc-run.sh.tpl" . | include "omec-control-plane.template" | indent 4 }}
+{{- range $key, $value := .Values.config.spgwc.cfgFiles }}
+  {{ $key }}: |-
+{{ $value | indent 4 }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/service-mme.yaml b/omec/omec-control-plane/templates/service-mme.yaml
index 265e9e8..0747919 100644
--- a/omec/omec-control-plane/templates/service-mme.yaml
+++ b/omec/omec-control-plane/templates/service-mme.yaml
@@ -18,17 +18,33 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: mme
+  name: mme-s11
   labels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 spec:
   selector:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  clusterIP: None
+{{- if .Values.config.mme.s11.nodePort.enabled }}
+  type: NodePort
+{{- end }}
   ports:
   - name: s11
-    port: {{ .Values.config.mme.s11.egtp_default_port }}
+    port: {{ .Values.config.mme.appConfig.s11.egtp_default_port }}
     protocol: UDP
+  {{- if .Values.config.mme.s11.nodePort.enabled }}
+    nodePort: {{ .Values.config.mme.s11.nodePort.port }}
+  {{- end }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: mme-s6a
+  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
@@ -36,7 +52,7 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: mme-sctp
+  name: mme-s1ap
   labels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
 spec:
@@ -45,6 +61,6 @@
   type: NodePort
   ports:
     - name: s1ap
-      port: {{ .Values.config.mme.s1ap.sctp_port }}
-      nodePort: {{ .Values.config.mme.s1ap.sctp_port_external }}
+      port: {{ .Values.config.mme.appConfig.s1ap.sctp_port }}
+      nodePort: {{ .Values.config.mme.appConfig.s1ap.sctp_port_external }}
       protocol: SCTP
diff --git a/omec/omec-control-plane/templates/service-spgwc.yaml b/omec/omec-control-plane/templates/service-spgwc.yaml
new file mode 100644
index 0000000..b406350
--- /dev/null
+++ b/omec/omec-control-plane/templates/service-spgwc.yaml
@@ -0,0 +1,56 @@
+{{/*
+Copyright 2019-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: Service
+metadata:
+  name: spgwc-cp-comm
+  labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+{{- if .Values.config.spgwc.cpComm.nodePort.enabled }}
+  type: NodePort
+{{- end }}
+  ports:
+  - name: cp-comm
+    port: 21
+    protocol: UDP
+  {{- if .Values.config.spgwc.cpComm.nodePort.enabled }}
+    nodePort: {{ .Values.config.spgwc.cpComm.nodePort.port }}
+  {{- end }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: spgwc-s11
+  labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+{{- if .Values.config.spgwc.s11.nodePort.enabled }}
+  type: NodePort
+{{- end }}
+  ports:
+  - name: s11
+    port: 2123
+    protocol: UDP
+  {{- if .Values.config.spgwc.s11.nodePort.enabled }}
+    nodePort: {{ .Values.config.spgwc.s11.nodePort.port }}
+  {{- end }}
diff --git a/omec/omec-control-plane/templates/spgwc.yaml b/omec/omec-control-plane/templates/spgwc.yaml
deleted file mode 100644
index 0b17a0f..0000000
--- a/omec/omec-control-plane/templates/spgwc.yaml
+++ /dev/null
@@ -1,544 +0,0 @@
-{{/*
-Copyright 2018-present Open Networking Foundation
-Copyright 2018 Intel Corporation
-
-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: ServiceAccount
-metadata:
-  name: spgwc
-  labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
----
-kind: Role
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: spgwc
-  labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-rules:
-- apiGroups: [""]
-  resources: ["pods"]
-  verbs: ["get"]
----
-kind: RoleBinding
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: spgwc
-  labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-roleRef:
-  apiGroup: rbac.authorization.k8s.io
-  kind: Role
-  name: spgwc
-subjects:
-- kind: ServiceAccount
-  name: spgwc
----
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: spgwc
-  labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-data:
-  launch.sh: |
-    #!/bin/bash -xe
-
-    RUN_DIR=${RUN_DIR:-"/opt/cp"}
-    mkdir -p $RUN_DIR/config
-    cd $RUN_DIR/config
-    cp /etc/cp/config/{adc_rules.cfg,cp_config.cfg,interface.cfg,meter_profile.cfg,pcc_rules.cfg,sdf_rules.cfg} .
-    sed -i "s/CP_ADDR/$CP_ADDR/g" interface.cfg
-    sed -i "s/DP_ADDR/$DP_ADDR/g" interface.cfg
-    sed -i "s/DP_PORT/$DP_PORT/g" interface.cfg
-    . cp_config.cfg
-    ngic_controlplane $EAL_ARGS -- $APP_ARGS
-  cp_config.cfg: |
-    if [ ! -d "/dev/hugepages" ]; then
-        MEMORY="--no-huge -m $((MEM_LIMIT-1024))"
-    fi
-    SHARED_DIR="/opt/cp/config/shared"
-    if [ -d ${SHARED_DIR} ]; then
-        while [ ! -f ${SHARED_DIR}/SGW_S1U_IP ]; do echo "Waiting for SGW_S1U_IP"; sleep 2; done
-        SGW_S1U_IP=$(cat ${SHARED_DIR}/SGW_S1U_IP)
-    fi
-    until dig +short ${MME_S11_IP} | grep -v -e '^$' > /dev/null; do
-        echo "Waiting for MME";
-        sleep 5;
-    done
-
-    MGMT_INFO="-s ${CP_ADDR} -m ${MME_S11_IP} -w ${SGW_S1U_IP}"
-    APN_INFO="-i ${IP_POOL_IP} -p ${IP_POOL_MASK} -a ${APN}"
-    SPGW_CFG="-d 03 -l 2 -r 7.7.7.7 -g 6.6.6.6 -v 4.4.4.4  -u 5.5.5.5"
-    APP_ARGS="${MGMT_INFO} ${APN_INFO} ${SPGW_CFG} ${TEID_INFO}"
-
-    CORES="-c $(taskset -p $$ | awk '{print $NF}')"
-    DEVICES="--no-pci"
-    EAL_ARGS="${CORES} ${MEMORY} ${DEVICES}"
-  interface.cfg: |
-    [0]
-    dp_comm_ip = DP_ADDR
-    dp_comm_port = DP_PORT
-    cp_comm_ip = CP_ADDR
-    cp_comm_port = 21
-  adc_rules.cfg: |
-    [GLOBAL]
-    NUM_ADC_RULES = 5
-
-    ;FORMAT ::
-    ;ADC_TYPE : [ DOMAIN = 0 | IP = 1 | IP PREFIX =2 ]
-    ;
-    ;if ADC_TYPE = 0
-    ;   DOMAIN
-    ;elseif ADC_TYPE = 1
-    ;   IP
-    ;elseif ADC_TYPE = 2
-    ;   IP
-    ;   PREFIX
-    ;else
-    ;   NONE
-    ;
-    ;NOTE :
-    ;Rules defined first have a higher priority, unless DROP is specified
-    ;(i.e. multiple rules for the same IP).
-    ;When specifying DROP with an IP address, use a prefix of 32 to prevent DNS
-    ;results from overwriting rule.
-
-
-    [ADC_RULE_1]
-    ADC_TYPE = 1
-    IP = 13.1.1.111
-
-    [ADC_RULE_2]
-    ADC_TYPE = 2
-    IP = 13.1.1.0
-    PREFIX = 24
-
-    [ADC_RULE_3]
-    ADC_TYPE = 1
-    IP = 13.1.1.112
-    PREFIX = 24
-
-    [ADC_RULE_4]
-    ADC_TYPE = 0
-    DOMAIN = www.example.gov
-
-    [ADC_RULE_5]
-    ADC_TYPE = 0
-    DOMAIN = www.drop_example.com
-  meter_profile.cfg: |
-    [GLOBAL]
-    NUM_OF_IDX = 7
-
-    [ENTRY_1]
-    ;Committed Information Rate (CIR). Measured in bytes per second.
-    ;MBR is mapped into CIR, convert MBR from bits to Bytes and set CIR.
-    CIR = 2342400
-    ;Committed Burst Size unit = Bytes
-    CBS = 5856
-    ;Excess Burst Size unit = Bytes
-    EBS = 11712
-    ;Meter profile index. Refer this index in static_pcc.cfg to set AMBR/MBR
-    MTR_PROFILE_IDX = 3
-
-    [ENTRY_2]
-    ;1200 = 1756800
-    ;1400 = 2049600
-    ;1600 = 2342400
-    CIR = 2342400
-    CBS = 5856
-    EBS = 11712
-    MTR_PROFILE_IDX = 4
-
-    [ENTRY_3]
-    ; QCI5,QCI7 15.571kbps = 1947 B
-    CIR = 2342400
-    CBS = 5856
-    EBS = 11712
-    MTR_PROFILE_IDX = 5
-
-    [ENTRY_4]
-    ; QCI1, 44kbps = 5500 B
-    CIR = 2342400
-    CBS = 5856
-    EBS = 11712
-    MTR_PROFILE_IDX = 6
-
-    [ENTRY_5]
-    ; QCI9, 31.143kbps = 3893 B
-    CIR = 2342400
-    CBS = 5856
-    EBS = 11712
-    MTR_PROFILE_IDX = 7
-
-    [ENTRY_6]
-    ; 128B, 7pps
-    CIR = 2342400
-    CBS = 512
-    EBS = 1024
-    MTR_PROFILE_IDX = 8
-
-    [ENTRY_7]
-    ; 128B, 2pps
-    CIR = 2342400
-    CBS = 512
-    EBS = 1024
-    MTR_PROFILE_IDX = 9
-
-  pcc_rules.cfg: |
-    [GLOBAL]
-    NUM_PCC_FILTERS = 9
-    ;To config AMBR/MBR values refer meter_profile.cfg. specify only the
-    ;meter profile index to be set here.
-    UL_AMBR_MTR_PROFILE_IDX = 3
-    DL_AMBR_MTR_PROFILE_IDX = 4
-
-    ;default filter - must be first for now (until DP doesn't install any filters)
-    ;associated with default adc rule
-    [PCC_FILTER_1]
-    RULE_NAME = DefaultRule
-    RATING_GROUP = 9
-    SERVICE_ID = 0
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 1
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = 0
-    REDIRECT_INFO = 0
-    PRECEDENCE = 254
-    DROP_PKT_COUNT = 0
-    ;Specify the meter profile index from meter_profile.cfg
-    UL_MBR_MTR_PROFILE_IDX = 7
-    DL_MBR_MTR_PROFILE_IDX = 7
-    ;List of ADC filter indices
-    SDF_FILTER_IDX = 99998
-
-    [PCC_FILTER_2]
-    RULE_NAME = sdf_rule_1
-    RATING_GROUP = 5
-    SERVICE_ID = 0
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 2
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = 0
-    REDIRECT_INFO = 0
-    PRECEDENCE = 1
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 5
-    DL_MBR_MTR_PROFILE_IDX = 5
-    ;List of SDF filter indices
-    SDF_FILTER_IDX = 1
-
-    [PCC_FILTER_3]
-    RULE_NAME = sdf_rule_2
-    RATING_GROUP = 1
-    SERVICE_ID = 0
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 3
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = 0
-    REDIRECT_INFO = 0
-    PRECEDENCE = 18
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 6
-    DL_MBR_MTR_PROFILE_IDX = 6
-    ;List of SDF filter indices
-    SDF_FILTER_IDX = 2
-
-    [PCC_FILTER_4]
-    RULE_NAME = adc_rule_1
-    RATING_GROUP = Zero-Rate
-    SERVICE_ID = Internet
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 8
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    REDIRECT_INFO = 0
-    SPONSOR_ID = Example
-    PRECEDENCE = 15
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 7
-    DL_MBR_MTR_PROFILE_IDX = 7
-    ;List of SDF filter indices
-    ADC_FILTER_IDX = 1
-
-    [PCC_FILTER_5]
-    RULE_NAME = adc_rule_2
-    RATING_GROUP = 0
-    SERVICE_ID = CIPA
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 9
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = Example
-    REDIRECT_INFO = 0
-    SPONSOR_ID = Example
-    REDIRECT_INFO = 0
-    PRECEDENCE = 4
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 0
-    DL_MBR_MTR_PROFILE_IDX = 0
-    ;List of SDF filter indices
-    ADC_FILTER_IDX = 2
-
-    [PCC_FILTER_6]
-    RULE_NAME = sdf_rule_3
-    RATING_GROUP = 7
-    SERVICE_ID = 0
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 4
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = 0
-    REDIRECT_INFO = 0
-    PRECEDENCE = 17
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 5
-    DL_MBR_MTR_PROFILE_IDX = 5
-    ;List of SDF filter indices
-    SDF_FILTER_IDX = 3
-
-    [PCC_FILTER_7]
-    RULE_NAME = adc_rule_3
-    RATING_GROUP = Zero-Rate
-    SERVICE_ID = Internet
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 5
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = Example
-    REDIRECT_INFO = 0
-    PRECEDENCE = 210
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 7
-    DL_MBR_MTR_PROFILE_IDX = 7
-    ;List of SDF filter indices
-    ADC_FILTER_IDX = 4
-
-    [PCC_FILTER_8]
-    RULE_NAME = adc_rule_4
-    RATING_GROUP = Zero-Rate
-    SERVICE_ID = Management
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 6
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = Example
-    REDIRECT_INFO = 0
-    PRECEDENCE = 200
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 7
-    DL_MBR_MTR_PROFILE_IDX = 7
-    ;List of SDF filter indices
-    ADC_FILTER_IDX = 12
-
-    [PCC_FILTER_9]
-    RULE_NAME = adc_rule_5
-    RATING_GROUP = Zero-Rate
-    SERVICE_ID = Provisioning
-    RULE_STATUS = 0
-    GATE_STATUS = 1
-    SESSION_CONT = 0
-    REPORT_LEVEL = 7
-    CHARGING_MODE = 0
-    METERING_METHOD = 0
-    MUTE_NOTIFY = 0
-    MONITORING_KEY = 0
-    SPONSOR_ID = Example
-    REDIRECT_INFO = 0
-    PRECEDENCE = 220
-    DROP_PKT_COUNT = 0
-    UL_MBR_MTR_PROFILE_IDX = 7
-    DL_MBR_MTR_PROFILE_IDX = 7
-    ;List of SDF filter indices
-    ADC_FILTER_IDX = 3
-  sdf_rules.cfg: |
-    [GLOBAL]
-    NUM_SDF_FILTERS = 4
-
-    [SDF_FILTER_1]
-    DIRECTION = downlink_only
-    IPV4_REMOTE = 13.2.1.113
-    IPV4_REMOTE_MASK = 255.255.255.0
-    PROTOCOL = 17
-    LOCAL_LOW_LIMIT_PORT = 0
-    LOCAL_HIGH_LIMIT_PORT = 65535
-    REMOTE_LOW_LIMIT_PORT = 0
-    REMOTE_HIGH_LIMIT_PORT = 65535
-
-    [SDF_FILTER_2]
-    DIRECTION = uplink_only
-    IPV4_LOCAL = 16.255.255.0
-    IPV4_LOCAL_MASK = 255.255.255.0
-    PROTOCOL = 17
-    LOCAL_LOW_LIMIT_PORT = 0
-    LOCAL_HIGH_LIMIT_PORT = 65535
-    REMOTE_LOW_LIMIT_PORT = 0
-    REMOTE_HIGH_LIMIT_PORT = 65535
-
-    [SDF_FILTER_3]
-    DIRECTION = downlink_only
-    IPV4_REMOTE = 130.10.0.0
-    IPV4_REMOTE_MASK = 255.255.0.0
-    PROTOCOL = 17
-    REMOTE_LOW_LIMIT_PORT = 5060
-    REMOTE_HIGH_LIMIT_PORT = 5060
-
-    [SDF_FILTER_4]
-    DIRECTION = uplink_only
-    IPV4_REMOTE = 103.1.0.0
-    IPV4_REMOTE_MASK = 255.255.0.0
-    PROTOCOL = 17
-    LOCAL_LOW_LIMIT_PORT = 17000
-    LOCAL_HIGH_LIMIT_PORT = 17010
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: spgwc
-  labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-spec:
-  selector:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-  clusterIP: None
-  ports:
-  - name: s11
-    port: 2123
-    protocol: UDP
-  - name: cpdp
-    port: 21
-    protocol: UDP
----
-apiVersion: apps/v1
-kind: StatefulSet
-metadata:
-  name: spgwc
-  labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-spec:
-  replicas: 1
-  selector:
-    matchLabels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 6 }}
-  serviceName: spgwc
-  template:
-    metadata:
-      labels:
-{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 8 }}
-    spec:
-    {{- if .Values.nodeSelectors.enabled }}
-      nodeSelector:
-        {{ .Values.nodeSelectors.spgwc.label }}: {{ .Values.nodeSelectors.spgwc.value }}
-    {{- end }}
-      serviceAccountName: spgwc
-      initContainers:
-      - name: init-spgwc
-        image: {{ .Values.images.tags.init }}
-        command: ["/bin/sh", "-co", "pipefail"]
-        args:
-        - until $(kubectl get pod -ojson spgwu-0 2>/dev/null | jq -r '.metadata.annotations["k8s.v1.cni.cncf.io/networks-status"]' | jq -r '.[] | select(.name=="s1u-net") | .ips[0]' > /opt/cp/config/shared/SGW_S1U_IP | [ -s /opt/cp/config/shared/SGW_S1U_IP ]);
-          do echo "waiting for SPGWU"; sleep 2; done
-        volumeMounts:
-        - name: shared-data
-          mountPath: /opt/cp/config/shared
-      containers:
-      - name: spgwc
-        image: {{ .Values.images.tags.spgwc }}
-        imagePullPolicy: {{ .Values.images.pullPolicy }}
-        stdin: true
-        tty: true
-        command: ["/opt/cp/scripts/launch.sh"]
-        env:
-        - name: MEM_LIMIT
-          valueFrom:
-            resourceFieldRef:
-              containerName: spgwc
-              resource: limits.memory
-              divisor: 1Mi
-        - name: CP_ADDR
-          valueFrom:
-            fieldRef:
-              fieldPath: status.podIP
-        - name: DP_ADDR
-          value: {{ .Values.config.spgwc.spgwu.addr | quote }}
-        - name: DP_PORT
-          value: {{ .Values.config.spgwc.spgwu.port | quote }}
-        - name: MME_S11_IP
-          value: {{ tuple "mme" "identity" . | include "omec-control-plane.endpoint_lookup" | quote }}
-        - name: APN
-          value: apn1
-        - name: IP_POOL_IP
-          value: "16.0.0.0"
-        - name: IP_POOL_MASK
-          value: "255.0.0.0"
-      {{- if .Values.resources.enabled }}
-        resources:
-{{ toYaml .Values.resources.spgwc | indent 10 }}
-      {{- end }}
-        volumeMounts:
-        - name: cp-script
-          mountPath: /opt/cp/scripts/launch.sh
-          subPath: launch.sh
-        - name: cp-config
-          mountPath: /etc/cp/config
-        - name: shared-data
-          mountPath: /opt/cp/config/shared
-      volumes:
-      - name: cp-script
-        configMap:
-          name: spgwc
-          defaultMode: 493
-      - name: cp-config
-        configMap:
-          name: spgwc
-          defaultMode: 420
-      - name: shared-data
-        emptyDir: {}
diff --git a/omec/omec-control-plane/templates/statefulset-mme.yaml b/omec/omec-control-plane/templates/statefulset-mme.yaml
index af37c34..745388b 100644
--- a/omec/omec-control-plane/templates/statefulset-mme.yaml
+++ b/omec/omec-control-plane/templates/statefulset-mme.yaml
@@ -14,49 +14,7 @@
 limitations under the License.
 */}}
 
----
-apiVersion: v1
-kind: ServiceAccount
-metadata:
-  name: mme
-  labels:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
----
-kind: Role
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: mme
-  labels:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-rules:
-  - apiGroups:
-      - ""
-      - extensions
-      - batch
-      - apps
-    verbs:
-      - get
-      - list
-    resources:
-      - daemonsets
-      - jobs
-      - pods
-      - services
-      - endpoints
----
-kind: RoleBinding
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: mme
-  labels:
-{{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 4 }}
-roleRef:
-  apiGroup: rbac.authorization.k8s.io
-  kind: Role
-  name: mme
-subjects:
-- kind: ServiceAccount
-  name: mme
+{{ tuple "mme" . | include "omec-control-plane.service_account" }}
 ---
 apiVersion: apps/v1
 kind: StatefulSet
@@ -69,7 +27,6 @@
   selector:
     matchLabels:
 {{ tuple "mme" . | include "omec-control-plane.metadata_labels" | indent 6 }}
-  serviceName: mme
   template:
     metadata:
       labels:
@@ -81,6 +38,26 @@
     {{- end }}
       serviceAccountName: mme
       initContainers:
+    {{- if not (hasKey .Values.config.spgwc "mmeAddr") }}
+      - name: mme-configmap-mme-ip
+        image: {{ .Values.images.tags.init | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        env:
+        - name: NAMESPACE
+          valueFrom:
+            fieldRef:
+              apiVersion: v1
+              fieldPath: metadata.namespace
+        - name: POD_IP
+          valueFrom:
+            fieldRef:
+              fieldPath: status.podIP
+        command: ["/opt/mme/scripts/mme-ip.sh"]
+        volumeMounts:
+        - name: scripts
+          mountPath: /opt/mme/scripts/mme-ip.sh
+          subPath: mme-ip.sh
+    {{- end }}
       - name: mme-dep-check
         image: {{ .Values.images.tags.depCheck | quote }}
         imagePullPolicy: {{ .Values.images.pullPolicy }}
@@ -104,7 +81,7 @@
           - name: COMMAND
             value: "echo done"
           - name: DEPENDENCY_POD_JSON
-            value: '[{"labels": {"app": "spgwc"}, "requireSameNode": false}, {"labels": {"app": "hss"}, "requireSameNode": false}]'
+            value: '[{"labels": {"app": "hss"}, "requireSameNode": false}]'
           # add dependency job for make_certs.sh
         command:
           - kubernetes-entrypoint
@@ -115,7 +92,7 @@
         imagePullPolicy: {{ .Values.images.pullPolicy }}
         command: ["/opt/mme/scripts/mme-init.sh"]
         env:
-        - name: MME_LOCAL_IP
+        - name: POD_IP
           valueFrom:
             fieldRef:
               fieldPath: status.podIP
diff --git a/omec/omec-control-plane/templates/statefulset-spgwc.yaml b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
new file mode 100644
index 0000000..9faadca
--- /dev/null
+++ b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
@@ -0,0 +1,106 @@
+{{/*
+Copyright 2019-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.
+*/}}
+
+{{ tuple "spgwc" . | include "omec-control-plane.service_account" }}
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: spgwc
+  labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 4 }}
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 6 }}
+  template:
+    metadata:
+      labels:
+{{ tuple "spgwc" . | include "omec-control-plane.metadata_labels" | indent 8 }}
+    spec:
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.spgwc.label }}: {{ .Values.nodeSelectors.spgwc.value }}
+    {{- end }}
+      serviceAccountName: spgwc
+      initContainers:
+      - name: spgwc-dep-check
+        image: {{ .Values.images.tags.depCheck | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        securityContext:
+          allowPrivilegeEscalation: false
+          readOnlyRootFilesystem: false
+          runAsUser: 0
+        env:
+          - name: POD_NAME
+            valueFrom:
+              fieldRef:
+                apiVersion: v1
+                fieldPath: metadata.name
+          - name: NAMESPACE
+            valueFrom:
+              fieldRef:
+                apiVersion: v1
+                fieldPath: metadata.namespace
+          - name: PATH
+            value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/
+          - name: COMMAND
+            value: "echo done"
+          - name: DEPENDENCY_POD_JSON
+            value: '[{"labels": {"app": "mme"}, "requireSameNode": false}]'
+      containers:
+      - name: spgwc
+        image: {{ .Values.images.tags.spgwc }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        stdin: true
+        tty: true
+        command: ["/opt/cp/scripts/spgwc-run.sh"]
+        env:
+        - name: MEM_LIMIT
+          valueFrom:
+            resourceFieldRef:
+              containerName: spgwc
+              resource: limits.memory
+              divisor: 1Mi
+        - name: POD_IP
+          valueFrom:
+            fieldRef:
+              fieldPath: status.podIP
+        - name: MME_ADDR
+          valueFrom:
+            configMapKeyRef:
+              name: mme-ip
+              key: IP
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.spgwc | indent 10 }}
+      {{- end }}
+        volumeMounts:
+        - name: cp-script
+          mountPath: /opt/cp/scripts/spgwc-run.sh
+          subPath: spgwc-run.sh
+        - name: cp-config
+          mountPath: /etc/cp/config
+      volumes:
+      - name: cp-script
+        configMap:
+          name: spgwc
+          defaultMode: 493
+      - name: cp-config
+        configMap:
+          name: spgwc
+          defaultMode: 420