Change directory name cdn-services to ott-services

Change-Id: I868d1370c25051c01cf94b7696e68a8099dccc09
diff --git a/ott-services/cdn-local/Chart.yaml b/ott-services/cdn-local/Chart.yaml
new file mode 100644
index 0000000..159c520
--- /dev/null
+++ b/ott-services/cdn-local/Chart.yaml
@@ -0,0 +1,20 @@
+---
+# 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
+appVersion: "1.0"
+description: A Helm chart for M-CORD CDN Services in Local Edge
+name: cdn-local
+version: 0.2.2
diff --git a/ott-services/cdn-local/templates/_helpers.tpl b/ott-services/cdn-local/templates/_helpers.tpl
new file mode 100644
index 0000000..fc1894f
--- /dev/null
+++ b/ott-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/ott-services/cdn-local/templates/bin/_network-config.sh.tpl b/ott-services/cdn-local/templates/bin/_network-config.sh.tpl
new file mode 100644
index 0000000..9402049
--- /dev/null
+++ b/ott-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/ott-services/cdn-local/templates/bin/_route-gen.sh.tpl b/ott-services/cdn-local/templates/bin/_route-gen.sh.tpl
new file mode 100644
index 0000000..7dcea6c
--- /dev/null
+++ b/ott-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/ott-services/cdn-local/templates/bin/_run-nginx.sh.tpl b/ott-services/cdn-local/templates/bin/_run-nginx.sh.tpl
new file mode 100644
index 0000000..cde099e
--- /dev/null
+++ b/ott-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/ott-services/cdn-local/templates/configmap-nginx.yaml b/ott-services/cdn-local/templates/configmap-nginx.yaml
new file mode 100644
index 0000000..1e505bd
--- /dev/null
+++ b/ott-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/ott-services/cdn-local/templates/networks.yaml b/ott-services/cdn-local/templates/networks.yaml
new file mode 100644
index 0000000..b3bf674
--- /dev/null
+++ b/ott-services/cdn-local/templates/networks.yaml
@@ -0,0 +1,32 @@
+{{/*
+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.
+*/}}
+
+{{ if .Values.config.sriov.enabled }}
+---
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+  name: sgi-net-cdn
+  annotations:
+    k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_netdevice
+spec:
+  config: '{
+    "type": {{ .Values.networks.cniPlugin | quote }},
+    "ipam": {
+        "type": {{ .Values.networks.ipam | quote }}
+    }
+  }'
+{{ end }}
\ No newline at end of file
diff --git a/ott-services/cdn-local/templates/service-nginx.yaml b/ott-services/cdn-local/templates/service-nginx.yaml
new file mode 100644
index 0000000..a0422b4
--- /dev/null
+++ b/ott-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/ott-services/cdn-local/templates/statefulset-nginx.yaml b/ott-services/cdn-local/templates/statefulset-nginx.yaml
new file mode 100644
index 0000000..1e67e1c
--- /dev/null
+++ b/ott-services/cdn-local/templates/statefulset-nginx.yaml
@@ -0,0 +1,110 @@
+{{/*
+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 }}
+{{ if .Values.config.sriov.enabled }}
+      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 }}
+          }
+        ]'
+{{ end }}
+    spec:
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.antMedia.label }}: {{ .Values.nodeSelectors.antMedia.value }}
+    {{- end }}
+      hostNetwork: {{ not .Values.config.sriov.enabled }}
+      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/ott-services/cdn-local/values.yaml b/ott-services/cdn-local/values.yaml
new file mode 100644
index 0000000..6f6e675
--- /dev/null
+++ b/ott-services/cdn-local/values.yaml
@@ -0,0 +1,118 @@
+---
+# 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.
+
+images:
+  tags:
+    nginx: docker.io/omecproject/cdn-nginx:1.0.0
+  pullPolicy: IfNotPresent
+
+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 # If you want to use Host Network, please unset this flag.
+    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:
+  cniPlugin: sriov # which means netdevice
+  ipam: static
+  sgi:
+    subnet: 13.1.1.0/24
+    mask: 255.255.255.0
+    gateway: 13.1.1.254
diff --git a/ott-services/cdn-remote/Chart.yaml b/ott-services/cdn-remote/Chart.yaml
new file mode 100644
index 0000000..b98a185
--- /dev/null
+++ b/ott-services/cdn-remote/Chart.yaml
@@ -0,0 +1,20 @@
+---
+# 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
+appVersion: "1.0"
+description: A Helm chart for M-CORD CDN Services in Remote Edge
+name: cdn-remote
+version: 0.2.2
diff --git a/ott-services/cdn-remote/templates/_helpers.tpl b/ott-services/cdn-remote/templates/_helpers.tpl
new file mode 100644
index 0000000..13c5543
--- /dev/null
+++ b/ott-services/cdn-remote/templates/_helpers.tpl
@@ -0,0 +1,104 @@
+{{- /*
+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-remote.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "cdn-remote.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
+
+{{/*
+Get Domain name
+*/}}
+{{- define "cdn-remote.get_domain" -}}
+{{- $service := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- printf "%s-0.%s.%s.%s" $service $service $context.Release.Namespace "svc.cluster.local" -}}
+{{- end -}}
+
+{{/*
+Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
+*/}}
+{{- define "cdn-remote.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-remote.metadata_labels" | indent 4 }}
+---
+apiVersion: rbac.authorization.k8s.io/v1beta1
+kind: RoleBinding
+metadata:
+  name: {{ $saName }}
+  namespace: {{ $saNamespace }}
+  labels:
+{{ tuple $saName $context | include "cdn-remote.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-remote.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/ott-services/cdn-remote/templates/bin/_start-stream.sh.tpl b/ott-services/cdn-remote/templates/bin/_start-stream.sh.tpl
new file mode 100644
index 0000000..2d928b3
--- /dev/null
+++ b/ott-services/cdn-remote/templates/bin/_start-stream.sh.tpl
@@ -0,0 +1,21 @@
+#!/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.
+
+QUALITY=$1
+
+while true; do
+    ffmpeg -re -i /opt/cdn/movies/$QUALITY.mp4 -c copy -f flv rtmp://{{ tuple "ant-media" . | include "cdn-remote.get_domain" }}:1935/LiveApp/$QUALITY;
+done
\ No newline at end of file
diff --git a/ott-services/cdn-remote/templates/configmap-video-archive.yaml b/ott-services/cdn-remote/templates/configmap-video-archive.yaml
new file mode 100644
index 0000000..ce73787
--- /dev/null
+++ b/ott-services/cdn-remote/templates/configmap-video-archive.yaml
@@ -0,0 +1,26 @@
+{{/*
+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: start-stream
+  labels:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 4 }}
+data:
+  start-stream.sh: |
+{{ tuple "bin/_start-stream.sh.tpl" . | include "cdn-remote.template" | indent 4 }}
diff --git a/ott-services/cdn-remote/templates/service-ant-media.yaml b/ott-services/cdn-remote/templates/service-ant-media.yaml
new file mode 100644
index 0000000..ba31e53
--- /dev/null
+++ b/ott-services/cdn-remote/templates/service-ant-media.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: ant-media
+  labels:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 4 }}
+  ports:
+  - name: httpui
+    port: {{ .Values.config.antMedia.ports.httpui }}
+    protocol: TCP
+  - name: rtmp
+    port: {{ .Values.config.antMedia.ports.rtmp }}
+    protocol: TCP
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: ant-media-external
+  labels:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 4 }}
+spec:
+  selector:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 4 }}
+  type: NodePort
+  ports:
+  - name: httpui
+    port: {{ .Values.config.antMedia.ports.httpui }}
+    protocol: TCP
+    nodePort: {{ .Values.config.antMedia.ports.nodePorts.httpui }}
+  - name: rtmp
+    port: {{ .Values.config.antMedia.ports.rtmp }}
+    protocol: TCP
+    nodePort: {{ .Values.config.antMedia.ports.nodePorts.rtmp }}
diff --git a/ott-services/cdn-remote/templates/statefulset-ant-media.yaml b/ott-services/cdn-remote/templates/statefulset-ant-media.yaml
new file mode 100644
index 0000000..1e9778a
--- /dev/null
+++ b/ott-services/cdn-remote/templates/statefulset-ant-media.yaml
@@ -0,0 +1,57 @@
+{{/*
+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 "ant-media" . | include "cdn-remote.service_account" }}
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: ant-media
+  labels:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 4 }}
+spec:
+  replicas: {{ .Values.config.antMedia.replicas }}
+  selector:
+    matchLabels:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 6 }}
+  serviceName: "ant-media"
+  template:
+    metadata:
+      labels:
+{{ tuple "ant-media" . | include "cdn-remote.metadata_labels" | indent 8 }}
+    spec:
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.antMedia.label }}: {{ .Values.nodeSelectors.antMedia.value }}
+    {{- end }}
+      serviceAccountName: ant-media
+      containers:
+      - name: ant-media
+        image: {{ .Values.images.tags.antMedia | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        securityContext:
+          allowPrivilegeEscalation: false
+          readOnlyRootFilesystem: false
+          runAsUser: 0
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+          - cd /usr/local/antmedia && ./start.sh | tee /opt/start.log
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.antMedia | indent 10 }}
+      {{- end }}
\ No newline at end of file
diff --git a/ott-services/cdn-remote/templates/statefulset-video-archive.yaml b/ott-services/cdn-remote/templates/statefulset-video-archive.yaml
new file mode 100644
index 0000000..4f515d1
--- /dev/null
+++ b/ott-services/cdn-remote/templates/statefulset-video-archive.yaml
@@ -0,0 +1,135 @@
+{{/*
+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 "video-archive" . | include "cdn-remote.service_account" }}
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: video-archive
+  labels:
+{{ tuple "video-archive" . | include "cdn-remote.metadata_labels" | indent 4 }}
+spec:
+  replicas: {{ .Values.config.videoArchive.replicas }}
+  selector:
+    matchLabels:
+{{ tuple "video-archive" . | include "cdn-remote.metadata_labels" | indent 6 }}
+  serviceName: "video-archive"
+  template:
+    metadata:
+      labels:
+{{ tuple "video-archive" . | include "cdn-remote.metadata_labels" | indent 8 }}
+    spec:
+    {{- if .Values.nodeSelectors.enabled }}
+      nodeSelector:
+        {{ .Values.nodeSelectors.videoArchive.label }}: {{ .Values.nodeSelectors.videoArchive.value }}
+    {{- end }}
+      serviceAccountName: video-archive
+      initContainers:
+      - name: video-archive-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": "ant-media"}, "requireSameNode": false}]'
+        command:
+          - kubernetes-entrypoint
+        volumeMounts:
+          []
+      containers:
+      - name: streaming-720
+        image: {{ .Values.images.tags.videoArchive | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        securityContext:
+          allowPrivilegeEscalation: false
+          readOnlyRootFilesystem: false
+          runAsUser: 0
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+        - /opt/start-stream.sh 720
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.videoArchive | indent 10 }}
+      {{- end }}
+        volumeMounts:
+        - name: start-script
+          mountPath: /opt/start-stream.sh
+          subPath: start-stream.sh
+      - name: streaming-480
+        image: {{ .Values.images.tags.videoArchive | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        securityContext:
+          allowPrivilegeEscalation: false
+          readOnlyRootFilesystem: false
+          runAsUser: 0
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+        - /opt/start-stream.sh 480
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.videoArchive | indent 10 }}
+      {{- end }}
+        volumeMounts:
+        - name: start-script
+          mountPath: /opt/start-stream.sh
+          subPath: start-stream.sh
+      - name: streaming-360
+        image: {{ .Values.images.tags.videoArchive | quote }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        securityContext:
+          allowPrivilegeEscalation: false
+          readOnlyRootFilesystem: false
+          runAsUser: 0
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+        - /opt/start-stream.sh 360
+      {{- if .Values.resources.enabled }}
+        resources:
+{{ toYaml .Values.resources.videoArchive | indent 10 }}
+      {{- end }}
+        volumeMounts:
+        - name: start-script
+          mountPath: /opt/start-stream.sh
+          subPath: start-stream.sh
+      volumes:
+      - name: start-script
+        configMap:
+          name: start-stream
+          defaultMode: 493
\ No newline at end of file
diff --git a/ott-services/cdn-remote/values.yaml b/ott-services/cdn-remote/values.yaml
new file mode 100644
index 0000000..3cc4542
--- /dev/null
+++ b/ott-services/cdn-remote/values.yaml
@@ -0,0 +1,59 @@
+---
+# 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.
+
+images:
+  tags:
+    videoArchive: docker.io/omecproject/cdn-video-repo:1.0.0
+    antMedia: docker.io/omecproject/cdn-antmedia:1.0.0
+    depCheck: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
+  pullPolicy: IfNotPresent
+
+nodeSelectors:
+  enabled: false
+  videoArchive:
+    label: videoArchive
+    value: enabled
+  antMedia:
+    label: antMedia
+    value: enabled
+
+resources:
+  enabled: true
+  videoArchive:
+    requests:
+      cpu: 3
+      memory: 1Gi
+    limits:
+      cpu: 3
+      memory: 1Gi
+  antMedia:
+    requests:
+      cpu: 3
+      memory: 1Gi
+    limits:
+      cpu: 3
+      memory: 1Gi
+
+config:
+  videoArchive:
+    replicas: 1
+  antMedia:
+    ports:
+      httpui: 5080
+      rtmp: 1935
+      nodePorts:
+        httpui: 32080
+        rtmp: 30935
+    replicas: 1