[COMAC-69] Add new open-source CDN for COMAC release

Change-Id: I2badabdeab92ededed927b2d8e462397ecd7a402
diff --git a/mcord-release/cdn-services/cdn-local/Chart.yaml b/mcord-release/cdn-services/cdn-local/Chart.yaml
new file mode 100644
index 0000000..d162d11
--- /dev/null
+++ b/mcord-release/cdn-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.0.1
diff --git a/mcord-release/cdn-services/cdn-local/templates/cm.yaml b/mcord-release/cdn-services/cdn-local/templates/cm.yaml
new file mode 100644
index 0000000..d6d7849
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-local/templates/cm.yaml
@@ -0,0 +1,77 @@
+---
+# 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;
+    ip route add {{ .Values.ue_ip_subnet2 }} via {{ .Values.spgwu_sgiip }} dev sgi-net;
+    ip link set sgi-net 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/mcord-release/cdn-services/cdn-local/templates/nginx.yaml b/mcord-release/cdn-services/cdn-local/templates/nginx.yaml
new file mode 100644
index 0000000..7c9548f
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-local/templates/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.
+
+---
+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", "interface": "sgi-net", "namespace": "default" }
+        ]'
+    spec:
+      #hostNetwork: true
+      nodeSelector:
+        kubernetes.io/hostname: {{ .Values.cdn_node_selector }}
+      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:
+            intel.com/sriov: '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: {}
\ No newline at end of file
diff --git a/mcord-release/cdn-services/cdn-local/values.yaml b/mcord-release/cdn-services/cdn-local/values.yaml
new file mode 100644
index 0000000..965456c
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-local/values.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.
+
+cdn_node_selector: node3
+nginx_hostname: "nginx"
+local_vlc_hostname: "local_vlc"
+
+remote_ip: 10.90.0.132
+stream_name: 1.stream
+spgwu_sgiip: 13.0.0.83
+ue_ip_subnet1: 16.0.0.0/8
+ue_ip_subnet2: 17.0.0.0/8
+
+nginx:
+  images:
+    nginx_image: "woojoong/nginx:onf-video-v3"
+  ports:
+    rtmp_orig: 1935
+    rtmp_np: 31935
+  replicas: 1
diff --git a/mcord-release/cdn-services/cdn-remote/Chart.yaml b/mcord-release/cdn-services/cdn-remote/Chart.yaml
new file mode 100644
index 0000000..719ccf3
--- /dev/null
+++ b/mcord-release/cdn-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.0.1
diff --git a/mcord-release/cdn-services/cdn-remote/templates/ant-media.yaml b/mcord-release/cdn-services/cdn-remote/templates/ant-media.yaml
new file mode 100644
index 0000000..0dc8efc
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-remote/templates/ant-media.yaml
@@ -0,0 +1,73 @@
+---
+# 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: antmedia
+spec:
+  selector:
+    app: antmedia
+  type: NodePort
+  ports:
+  - name: httpui
+    port: {{ .Values.antmedia.ports.httpui }}
+    nodePort: {{ .Values.antmedia.ports.httpui_np }}
+    protocol: TCP
+  - name: rtmp
+    port: {{ .Values.antmedia.ports.rtmp }}
+    nodePort: {{ .Values.antmedia.ports.rtmp_np }}
+    protocol: TCP
+
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: antmedia
+  labels:
+    name: antmedia
+    app: antmedia
+spec:
+  replicas: {{ .Values.antmedia.replicas }}
+  selector:
+    matchLabels:
+      app: antmedia
+  serviceName: "antmedia"
+  template:
+    metadata:
+      labels:
+        app: antmedia
+        name: antmedia
+    spec:
+      terminationGracePeriodSeconds: 1
+      nodeSelector:
+        kubernetes.io/hostname: {{ .Values.cdn_node_selector }}
+      containers:
+      - name: antmedia
+        image: {{ .Values.antmedia.images.antmedia_image }}
+        imagePullPolicy: IfNotPresent
+        ports:
+        - containerPort: {{ .Values.antmedia.ports.httpui }}
+        - containerPort: {{ .Values.antmedia.ports.rtmp }}
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+          - cd /usr/local/antmedia && ./start.sh | tee /opt/start.log
+        resources:
+          limits:
+            cpu: {{ .Values.antmedia.resources.cpu }}
+            memory: {{ .Values.antmedia.resources.mem }}
\ No newline at end of file
diff --git a/mcord-release/cdn-services/cdn-remote/templates/cm.yaml b/mcord-release/cdn-services/cdn-remote/templates/cm.yaml
new file mode 100644
index 0000000..6b419c5
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-remote/templates/cm.yaml
@@ -0,0 +1,24 @@
+---
+# 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-remote-stream
+data:
+  start-remote-stream.sh: |+
+    #!/bin/bash
+    while true; do ffmpeg -re -i /opt/cdn/movies/{{ .Values.remote_streaming.video_quality }}.mp4 -c copy -f flv rtmp://{{ .Values.remote_streaming.antmedia_ip }}:30935/LiveApp/{{ .Values.stream_name }}; done
\ No newline at end of file
diff --git a/mcord-release/cdn-services/cdn-remote/templates/remote-streamer.yaml b/mcord-release/cdn-services/cdn-remote/templates/remote-streamer.yaml
new file mode 100644
index 0000000..b974c44
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-remote/templates/remote-streamer.yaml
@@ -0,0 +1,80 @@
+---
+# 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: remote-streaming
+spec:
+  selector:
+    app: remote-streaming
+  type: NodePort
+  ports:
+  - name: vlc
+    port: {{ .Values.remote_streaming.ports.vlc }}
+    nodePort: {{ .Values.remote_streaming.ports.vlc_np }}
+    protocol: TCP
+  - name: http
+    port: {{ .Values.remote_streaming.ports.http }}
+    nodePort: {{ .Values.remote_streaming.ports.http_np }}
+    protocol: TCP
+
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+  name: remote-streaming
+spec:
+  replicas: {{ .Values.remote_streaming.replicas }}
+  selector:
+    matchLabels:
+      app: remote-streaming
+  serviceName: "remote-streaming"
+  template:
+    metadata:
+      labels:
+        app: remote-streaming
+        name: remote-streaming
+    spec:
+      terminationGracePeriodSeconds: 1
+      nodeSelector:
+        kubernetes.io/hostname: {{ .Values.cdn_node_selector }}
+      containers:
+      - name: streaming
+        image: {{ .Values.remote_streaming.images.remote_streaming_image }}
+        imagePullPolicy: IfNotPresent
+        ports:
+        - containerPort: {{ .Values.remote_streaming.ports.vlc }}
+        - containerPort: {{ .Values.remote_streaming.ports.http }}
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+        - sed -i 's/geteuid/getppid/' /usr/bin/vlc;
+          /opt/start-remote-stream.sh
+        resources:
+          limits:
+            cpu: {{ .Values.remote_streaming.resources.cpu }}
+            memory: {{ .Values.remote_streaming.resources.mem }}
+        volumeMounts:
+        - name: start-script
+          mountPath: /opt/start-remote-stream.sh
+          subPath: start-remote-stream.sh
+      volumes:
+      - name: start-script
+        configMap:
+          name: start-remote-stream
+          defaultMode: 493
\ No newline at end of file
diff --git a/mcord-release/cdn-services/cdn-remote/values.yaml b/mcord-release/cdn-services/cdn-remote/values.yaml
new file mode 100644
index 0000000..e1e8ad8
--- /dev/null
+++ b/mcord-release/cdn-services/cdn-remote/values.yaml
@@ -0,0 +1,47 @@
+---
+# 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.
+
+namespace: remotecdn
+cdn_node_selector: node2
+remote_streaming_hostname: "remote-streaming"
+stream_name: 1.stream
+
+remote_streaming:
+  video_quality: 360
+  antmedia_ip: 10.90.0.132
+  images:
+    remote_streaming_image: "woojoong/mwc-cdn:remote-v3"
+  ports:
+    vlc: 8089
+    vlc_np: 31889
+    http: 50001
+    http_np: 31501
+  replicas: 1
+  resources:
+    cpu: 3
+    mem: "1Gi"
+
+antmedia:
+  images:
+    antmedia_image: "woojoong/antmedia:1.7.0"
+  ports:
+    httpui: 5080
+    httpui_np: 32080
+    rtmp: 1935
+    rtmp_np: 30935
+  replicas: 1
+  resources:
+    cpu: 3
+    mem: "1Gi"