[COMAC-174] CDN-Local code refactoring - only possible to use SRIOV

- remove unnecessary values in values.yaml
- use camel case
- rename nginx-rtmp to nginx
- allow CDN-Local to use multiple CDN-Remotes
- pull all videos from all CDN-Remotes
- define Roles, RoleBinding, ServiceAccount
- split each POD yaml file into Service, ConfigMap, and StatefulSet
- Remove hard coded values in Service, ConfigMap, and StatefulSet and
then locate them to values.yaml

Change-Id: Ib7c0d674f5aa4118274f1aad6888e373ef5c97be
diff --git a/cdn-services/cdn-local/Chart.yaml b/cdn-services/cdn-local/Chart.yaml
index 765fec3..f978c77 100644
--- a/cdn-services/cdn-local/Chart.yaml
+++ b/cdn-services/cdn-local/Chart.yaml
@@ -17,4 +17,4 @@
 appVersion: "1.0"
 description: A Helm chart for M-CORD CDN Services in Local Edge
 name: cdn-local
-version: 0.1.2-dev
+version: 0.1.3-dev
diff --git a/cdn-services/cdn-local/templates/_helpers.tpl b/cdn-services/cdn-local/templates/_helpers.tpl
new file mode 100644
index 0000000..fc1894f
--- /dev/null
+++ b/cdn-services/cdn-local/templates/_helpers.tpl
@@ -0,0 +1,95 @@
+{{- /*
+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.
+*/ -}}
+
+{{/*
+Renders a set of standardised labels
+*/}}
+{{- define "cdn-local.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "cdn-local.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
+
+{{/*
+Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
+*/}}
+{{- define "cdn-local.service_account" -}}
+{{- $saName := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $saNamespace := $context.Release.Namespace }}
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: {{ $saName }}
+  namespace: {{ $saNamespace }}
+  labels:
+{{ tuple $saName $context | include "cdn-local.metadata_labels" | indent 4 }}
+---
+apiVersion: rbac.authorization.k8s.io/v1beta1
+kind: RoleBinding
+metadata:
+  name: {{ $saName }}
+  namespace: {{ $saNamespace }}
+  labels:
+{{ tuple $saName $context | include "cdn-local.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 "cdn-local.metadata_labels" | indent 4 }}
+rules:
+  - apiGroups:
+      - ""
+      - extensions
+      - batch
+      - apps
+    verbs:
+      - get
+      - list
+      - patch
+    resources:
+      - statefulsets
+      - daemonsets
+      - jobs
+      - pods
+      - services
+      - endpoints
+      - configmaps
+{{- end -}}
\ No newline at end of file
diff --git a/cdn-services/cdn-local/templates/bin/_network-config.sh.tpl b/cdn-services/cdn-local/templates/bin/_network-config.sh.tpl
new file mode 100644
index 0000000..9402049
--- /dev/null
+++ b/cdn-services/cdn-local/templates/bin/_network-config.sh.tpl
@@ -0,0 +1,17 @@
+#!/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.
+
+ip link set {{ .Values.config.nginx.sgi.device }} mtu {{ .Values.config.nginx.mtu }}
\ No newline at end of file
diff --git a/cdn-services/cdn-local/templates/bin/_route-gen.sh.tpl b/cdn-services/cdn-local/templates/bin/_route-gen.sh.tpl
new file mode 100644
index 0000000..7dcea6c
--- /dev/null
+++ b/cdn-services/cdn-local/templates/bin/_route-gen.sh.tpl
@@ -0,0 +1,32 @@
+#!/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.
+
+SPGWU_IP=$(echo {{ .Values.config.spgwu.sgi.ip }} | awk -F '/' '{print $1}')
+
+netmask_to_prefix() {
+    prefix=0
+    octat=0$( printf '%o' ${1//./ } )
+    while [ $octat -gt 0 ];
+    do
+        prefix=$(( $prefix + $(( $octat % 2))))
+        octat=$(( $octat >> 1))
+    done
+    echo $prefix
+}
+
+ip route add {{ .Values.config.spgwc.ueIpPool.ip }}/$(netmask_to_prefix {{ .Values.config.spgwc.ueIpPool.mask }} ) via $SPGWU_IP dev {{ .Values.config.nginx.sgi.device }}
+
+
diff --git a/cdn-services/cdn-local/templates/bin/_run-nginx.sh.tpl b/cdn-services/cdn-local/templates/bin/_run-nginx.sh.tpl
new file mode 100644
index 0000000..cde099e
--- /dev/null
+++ b/cdn-services/cdn-local/templates/bin/_run-nginx.sh.tpl
@@ -0,0 +1,18 @@
+#!/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.
+
+cp /conf/nginx.conf  /etc/nginx/
+nginx -g "daemon off;"
\ No newline at end of file
diff --git a/cdn-services/cdn-local/templates/cm.yaml b/cdn-services/cdn-local/templates/cm.yaml
deleted file mode 100644
index 49b5f95..0000000
--- a/cdn-services/cdn-local/templates/cm.yaml
+++ /dev/null
@@ -1,77 +0,0 @@
----
-# 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: nginx-rtmp-config
-data:
-  nginx_rtmp_config.sh: |+
-    #!/bin/bash
-    ip route add {{ .Values.ue_ip_subnet1 }} via {{ .Values.spgwu_sgiip }} dev sgi-net-nd;
-    ip route add {{ .Values.ue_ip_subnet2 }} via {{ .Values.spgwu_sgiip }} dev sgi-net-nd;
-    ip link set sgi-net-nd mtu 1200;
-    cp /conf/nginx.conf  /etc/nginx/
-    nginx -g "daemon off;"
----
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: nginx-rtmp-conf
-data:
-  nginx.conf: |+
-    worker_processes  1;
-
-    events {
-        worker_connections  1024;
-    }
-
-
-    http {
-        include       mime.types;
-        default_type  application/octet-stream;
-
-        sendfile        on;
-        keepalive_timeout  65;
-
-        server {
-            listen       8085;
-            server_name  localhost;
-
-            location / {
-                root   html;
-                index  index.html index.htm;
-            }
-
-            error_page   500 502 503 504  /50x.html;
-            location = /50x.html {
-                root   html;
-            }
-        }
-    }
-    rtmp {
-        server {
-            listen 1935;
-            chunk_size 4000;
-            application r {
-               live on;
-               pull rtmp://{{ .Values.remote_ip }}:30935/LiveApp/{{ .Values.stream_name }};
-            }
-            application l {
-               play /opt/cdn/movies;
-            }
-        }
-    }
diff --git a/cdn-services/cdn-local/templates/configmap-nginx.yaml b/cdn-services/cdn-local/templates/configmap-nginx.yaml
new file mode 100644
index 0000000..1e505bd
--- /dev/null
+++ b/cdn-services/cdn-local/templates/configmap-nginx.yaml
@@ -0,0 +1,98 @@
+{{/*
+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: nginx-net-config
+  labels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+data:
+  route-gen.sh: |
+{{ tuple "bin/_route-gen.sh.tpl" . | include "cdn-local.template" | indent 4 }}
+  network-config.sh: |
+{{ tuple "bin/_network-config.sh.tpl" . | include "cdn-local.template" | indent 4 }}
+  run-nginx.sh: |
+{{ tuple "bin/_run-nginx.sh.tpl" . | include "cdn-local.template" | indent 4 }}
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: nginx-rtmp-config
+  labels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+data:
+  nginx.conf: |+
+    worker_processes {{ .Values.config.nginx.events.workerProcesses }};
+
+    events {
+      worker_connections {{ .Values.config.nginx.events.workerConnections }};
+    }
+
+    http {
+      include mime.types;
+
+      default_type {{ .Values.config.nginx.http.defaultType }};
+
+      sendfile {{ .Values.config.nginx.http.sendfile }};
+
+      keepalive_timeout {{ .Values.config.nginx.http.keepaliveTimeout }};
+
+      server {
+        listen {{ .Values.config.nginx.ports.http }};
+
+        server_name {{ .Values.config.nginx.http.server.serverName }};
+
+        location / {
+          root {{ .Values.config.nginx.http.server.location.root }};
+
+          index {{ .Values.config.nginx.http.server.location.index }};
+        }
+
+        error_page {{ .Values.config.nginx.http.server.error.code }} {{ .Values.config.nginx.http.server.error.page }};
+
+        location = {{ .Values.config.nginx.http.server.error.page }} {
+          root {{ .Values.config.nginx.http.server.error.root }};
+        }
+      }
+    }
+
+    rtmp {
+      server{
+        listen {{ .Values.config.nginx.ports.rtmp }};
+
+        chunk_size {{ .Values.config.nginx.rtmp.chunkSize }};
+
+        {{ range .Values.config.cdnRemotes }}
+        {{- $cdnRemote := . -}}
+        # name: {{ .name }}
+        application {{ $.Values.config.nginx.rtmp.appRemote.name }}/{{ $cdnRemote.name }} {
+          live {{ $.Values.config.nginx.rtmp.appRemote.live }};
+
+          {{- range .streams }}
+          pull rtmp://{{ $cdnRemote.ip }}:{{ $cdnRemote.port }}/LiveApp/{{ .value }} name={{ .value }};
+          {{- end }}
+
+        }
+        {{ end }}
+
+        application {{ .Values.config.nginx.rtmp.appLocal.name }} {
+          play {{ .Values.config.nginx.rtmp.appLocal.movieLocation }};
+        }
+      }
+    }
\ No newline at end of file
diff --git a/cdn-services/cdn-local/templates/networks.yaml b/cdn-services/cdn-local/templates/networks.yaml
index 3af289c..54b44a2 100644
--- a/cdn-services/cdn-local/templates/networks.yaml
+++ b/cdn-services/cdn-local/templates/networks.yaml
@@ -1,32 +1,32 @@
----
-# 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.
+{{/*
+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: "k8s.cni.cncf.io/v1"
 kind: NetworkAttachmentDefinition
 metadata:
-  name: sgi-net-nd
-{{- if .Values.networks.sriov.enabled }}
+  name: sgi-net-cdn
+{{- if .Values.config.sriov.enabled }}
   annotations:
     k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_netdevice
 {{- end }}
 spec:
   config: '{
-    "type": {{ .Values.networks.sgi_net_nd.type | quote }},
+    "type": {{ .Values.networks.cniPlugin | quote }},
     "ipam": {
-        "type": {{ .Values.networks.sgi_net_nd.ipam | quote }}
+        "type": {{ .Values.networks.ipam | quote }}
     }
   }'
diff --git a/cdn-services/cdn-local/templates/nginx.yaml b/cdn-services/cdn-local/templates/nginx.yaml
deleted file mode 100644
index 5d81825..0000000
--- a/cdn-services/cdn-local/templates/nginx.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
----
-# 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: nginx-rtmp
-spec:
-  selector:
-    app: nginx-rtmp
-  type: NodePort
-  ports:
-  - name: vlc
-    port: {{ .Values.nginx.ports.rtmp_orig }}
-    nodePort: {{ .Values.nginx.ports.rtmp_np }}
-    protocol: TCP
-
----
-apiVersion: apps/v1beta1
-kind: StatefulSet
-metadata:
-  name: nginx-rtmp
-spec:
-  serviceName: nginx-rtmp
-  replicas: 1
-  template:
-    metadata:
-      labels:
-        name: nginx-rtmp
-        app: nginx-rtmp
-      annotations:
-        k8s.v1.cni.cncf.io/networks: '[
-            { "name": "sgi-net-nd", "interface": "sgi-net-nd", "ips": {{ .Values.networks.sgi_net_nd.ip | quote }} }
-        ]'
-    spec:
-      #hostNetwork: true
-      terminationGracePeriodSeconds: 0
-      imagePullSecrets:
-      - name: nexus-docker-secret
-      initContainers:
-      - name: "nginx-rtmp-init"
-        image: {{ .Values.nginx.images.nginx_image }}
-        imagePullPolicy: "IfNotPresent"
-        args:
-        - cp /config/*.sh /shared-vol;cp /conf/* /shared-vol
-        command:
-        - "/bin/bash"
-        - "-c"
-        volumeMounts:
-        - name: "shared-volume"
-          mountPath: "/shared-vol"
-        - name: "nginx-rtmp-config"
-          mountPath: "/config"
-        - name: "nginx-rtmp-conf"
-          mountPath: "/conf"
-      containers:
-      - name: nginx-rtmp
-        image: {{ .Values.nginx.images.nginx_image }}
-        imagePullPolicy: IfNotPresent
-        args:
-        - chmod a+x /config/*.sh;/config/nginx_rtmp_config.sh
-        command:
-        - "/bin/bash"
-        - "-c"
-        tty: true
-        securityContext:
-          privileged: true
-        ports:
-        - containerPort: {{ .Values.nginx.ports.rtmp_orig }}
-        volumeMounts:
-        - name: shared-volume
-          mountPath: /config
-        - name: shared-volume
-          mountPath: /conf
-        resources:
-          limits:
-            cpu: {{ .Values.nginx.resources.cpu }}
-            memory: {{ .Values.nginx.resources.mem }}
-            intel.com/sriov_netdevice: '2'
-      volumes:
-      - name: nginx-rtmp-config
-        configMap:
-          name: nginx-rtmp-config
-          items:
-          - key: nginx_rtmp_config.sh
-            path: nginx_rtmp_config.sh
-      - name: nginx-rtmp-conf
-        configMap:
-          name: nginx-rtmp-conf
-          items:
-          - key: nginx.conf
-            path: nginx.conf
-      - name: shared-volume
-        emptyDir: {}
diff --git a/cdn-services/cdn-local/templates/service-nginx.yaml b/cdn-services/cdn-local/templates/service-nginx.yaml
new file mode 100644
index 0000000..a0422b4
--- /dev/null
+++ b/cdn-services/cdn-local/templates/service-nginx.yaml
@@ -0,0 +1,54 @@
+{{/*
+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: nginx
+  labels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+  ports:
+  - name: http
+    port: {{ .Values.config.nginx.ports.http }}
+    protocol: TCP
+  - name: rtmp
+    port: {{ .Values.config.nginx.ports.rtmp }}
+    protocol: TCP
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: nginx-external
+  labels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+  type: NodePort
+  ports:
+  - name: http
+    port: {{ .Values.config.nginx.ports.http }}
+    protocol: TCP
+    nodePort: {{ .Values.config.nginx.ports.nodePorts.http }}
+  - name: rtmp
+    port: {{ .Values.config.nginx.ports.rtmp }}
+    protocol: TCP
+    nodePort: {{ .Values.config.nginx.ports.nodePorts.rtmp }}
\ No newline at end of file
diff --git a/cdn-services/cdn-local/templates/statefulset-nginx.yaml b/cdn-services/cdn-local/templates/statefulset-nginx.yaml
new file mode 100644
index 0000000..93b1f13
--- /dev/null
+++ b/cdn-services/cdn-local/templates/statefulset-nginx.yaml
@@ -0,0 +1,107 @@
+{{/*
+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 "nginx" . | include "cdn-local.service_account" }}
+
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: nginx
+  labels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+spec:
+  replicas: {{ .Values.config.nginx.replicas }}
+  selector:
+    matchLabels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 6 }}
+  serviceName: "nginx"
+  template:
+    metadata:
+      labels:
+{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 8 }}
+      annotations:
+        k8s.v1.cni.cncf.io/networks: '[
+          {
+            "name": "sgi-net-cdn",
+            "interface": {{ .Values.config.nginx.sgi.device | quote }},
+            "ips": {{ .Values.config.nginx.sgi.ip | quote }}
+          }
+        ]'
+    spec:
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.antMedia.label }}: {{ .Values.nodeSelectors.antMedia.value }}
+    {{- end }}
+      serviceAccountName: nginx
+      initContainers:
+      - name: nginx-init
+        image: {{ .Values.images.tags.nginx }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        securityContext:
+          allowPrivilegeEscalation: false
+          readOnlyRootFilesystem: false
+          runAsUser: 0
+        command: [ "bash",  "-xc"]
+        args:
+        - cp /config/*.sh /shared-vol;cp /conf/* /shared-vol
+        volumeMounts:
+        - name: shared-volume
+          mountPath: /shared-vol
+        - name: nginx-net-config
+          mountPath: /config
+        - name: nginx-rtmp-config
+          mountPath: /conf
+      containers:
+      - name: nginx
+        image: {{ .Values.images.tags.nginx }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        command: [ "bash",  "-xc"]
+        args:
+        - chmod a+x /config/*.sh; /config/route-gen.sh; /config/network-config.sh; /config/run-nginx.sh
+        securityContext:
+          privileged: true
+        volumeMounts:
+        - name: shared-volume
+          mountPath: /config
+        - name: shared-volume
+          mountPath: /conf
+        resources:
+          requests:
+          {{- if .Values.resources.enabled }}
+{{ toYaml .Values.resources.nginx.requests | indent 12 }}
+          {{- end }}
+          {{- if .Values.config.sriov.enabled }}
+            intel.com/sriov_netdevice: 2
+          {{- end }}
+          limits:
+          {{- if .Values.resources.enabled }}
+{{ toYaml .Values.resources.nginx.limits | indent 12 }}
+          {{- end }}
+          {{- if .Values.config.sriov.enabled }}
+            intel.com/sriov_netdevice: 2
+          {{- end }}
+      volumes:
+      - name: nginx-net-config
+        configMap:
+          name: nginx-net-config
+          defaultMode: 493
+      - name: nginx-rtmp-config
+        configMap:
+          name: nginx-rtmp-config
+          defaultMode: 420
+      - name: shared-volume
+        emptyDir: {}
\ No newline at end of file
diff --git a/cdn-services/cdn-local/values.yaml b/cdn-services/cdn-local/values.yaml
index ae81f57..069b9d1 100644
--- a/cdn-services/cdn-local/values.yaml
+++ b/cdn-services/cdn-local/values.yaml
@@ -13,29 +13,106 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-remote_ip: 10.90.0.132
-stream_name: 1.stream
-spgwu_sgiip: 13.1.1.3
-ue_ip_subnet1: 16.0.0.0/8
-ue_ip_subnet2: 17.0.0.0/8
+images:
+  tags:
+    nginx: docker.io/omecproject/cdn-nginx:1.0.0
+  pullPolicy: IfNotPresent
 
-nginx:
-  images:
-    nginx_image: "docker.io/omecproject/cdn-nginx:1.0.0"
-  ports:
-    rtmp_orig: 1935
-    rtmp_np: 31935
-  replicas: 1
-  resources:
-    cpu: 3
-    mem: "1Gi"
+nodeSelectors:
+  enabled: false
+  nginx:
+    label: nginx
+    value: enabled
+
+resources:
+  enabled: true
+  nginx:
+    requests:
+      cpu: 3
+      memory: 1Gi
+    limits:
+      cpu: 3
+      memory: 1Gi
+
+config:
+  sriov:
+    enabled: true # default value. Do not use here as false now.
+    netDevice:
+      pfNames:
+        - eno2
+      drivers:
+        - ixgbevf
+        - i40evf
+  nginx:
+    ports:
+      rtmp: 1935
+      http: 8085
+      nodePorts:
+        enabled: true
+        rtmp: 31935
+        http: 31885
+    sgi:
+      device: sgi-net-cdn
+      ip: 13.1.1.253/24
+    mtu: 1200
+    events:
+      workerProcesses: 1
+      workerConnections: 1024
+    http:
+      defaultType: application/octet-stream
+      sendfile: "on"
+      keepaliveTimeout: 65
+      server:
+        serverName: localhost
+        location:
+          root: html
+          index: index.html index.htm
+        error:
+          code: 500 502 503 504
+          page: /50x.html
+          root: html
+    rtmp:
+      chunkSize: 4000
+      appRemote:
+        name: r
+        live: "on"
+      appLocal:
+        name: l
+        movieLocation: /opt/cdn/movies
+    replicas: 1
+  cdnRemotes:
+  - name: remote-1
+    ip: 10.90.0.131
+    port: 30935
+    streams:
+    - name: 360p
+      value: 360
+    - name: 480p
+      value: 480
+    - name: 720p
+      value: 720
+#  - name: CDN-Remote-2
+#    ip: 10.90.0.151
+#    port: 30935
+#    streams:
+#    - name: 360p
+#      value: 360
+#    - name: 480p
+#      value: 480
+#    - name: 720p
+#      value: 720
+  spgwu:
+    sgi:
+      ip: 13.1.1.3/24
+  spgwc:
+    ueIpPool:
+      ip: 16.0.0.0
+      mask: 255.0.0.0
 
 networks:
-  sriov:
-    enabled: true
-  sgi_net_nd:
-    type: sriov
-    ipam: static
-    ip: 13.1.1.253/24
+  cniPlugin: sriov # which means netdevice
+  ipam: static
+  sgi:
     subnet: 13.1.1.0/24
+    mask: 255.255.255.0
     gateway: 13.1.1.254