add local and remote cdn -- Infosys

Change-Id: I0f74ed33bbf9ca3434037a3dabf8bcdc3764a0bc
diff --git a/mcord/mcord-cdn-local/Chart.yaml b/mcord/mcord-cdn-local/Chart.yaml
new file mode 100644
index 0000000..e49a4bc
--- /dev/null
+++ b/mcord/mcord-cdn-local/Chart.yaml
@@ -0,0 +1,21 @@
+---
+# 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
+appVersion: "1.0"
+description: A Helm chart for MCORD CDN Services in Local Edge
+name: mcord-cdn-local
+version: 0.1.1
diff --git a/mcord/mcord-cdn-local/templates/cm.yaml b/mcord/mcord-cdn-local/templates/cm.yaml
new file mode 100644
index 0000000..cd91d48
--- /dev/null
+++ b/mcord/mcord-cdn-local/templates/cm.yaml
@@ -0,0 +1,170 @@
+---
+# Copyright 2018-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 addr add 192.168.99.2 dev north0
+    #ip addr add 192.168.99.3 dev north0d1
+    #ip route del default dev eth0
+    #ip route add default gw 192.168.99.2 north0
+    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 -c /etc/nginx/nginx.conf
+    #while true; do sleep 1; done
+    nginx -g "daemon off;"
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: nginx-rtmp-conf
+data:
+  nginx.conf: |+
+    #user  nobody;
+    worker_processes  1;
+
+    #error_log  logs/error.log;
+    #error_log  logs/error.log  notice;
+    #error_log  logs/error.log  info;
+
+    #pid        logs/nginx.pid;
+
+
+    events {
+        worker_connections  1024;
+    }
+
+
+    http {
+        include       mime.types;
+        default_type  application/octet-stream;
+
+        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+        #                  '$status $body_bytes_sent "$http_referer" '
+        #                  '"$http_user_agent" "$http_x_forwarded_for"';
+
+        #access_log  logs/access.log  main;
+
+        sendfile        on;
+        #tcp_nopush     on;
+
+        #keepalive_timeout  0;
+        keepalive_timeout  65;
+
+        #gzip  on;
+
+        server {
+            listen       8085;
+            server_name  localhost;
+
+            #charset koi8-r;
+
+            #access_log  logs/host.access.log  main;
+
+            location / {
+                root   html;
+                index  index.html index.htm;
+            }
+
+            #error_page  404              /404.html;
+
+            # redirect server error pages to the static page /50x.html
+            #
+            error_page   500 502 503 504  /50x.html;
+            location = /50x.html {
+                root   html;
+            }
+
+            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+            #
+            #location ~ \.php$ {
+            #    proxy_pass   http://127.0.0.1;
+            #}
+
+            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+            #
+            #location ~ \.php$ {
+            #    root           html;
+            #    fastcgi_pass   127.0.0.1:9000;
+            #    fastcgi_index  index.php;
+            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
+            #    include        fastcgi_params;
+            #}
+
+            # deny access to .htaccess files, if Apache's document root
+            # concurs with nginx's one
+            #
+            #location ~ /\.ht {
+            #    deny  all;
+            #}
+        }
+
+
+        # another virtual host using mix of IP-, name-, and port-based configuration
+        #
+        #server {
+        #    listen       8000;
+        #    listen       somename:8080;
+        #    server_name  somename  alias  another.alias;
+
+        #    location / {
+        #        root   html;
+        #        index  index.html index.htm;
+        #    }
+        #}
+
+
+        # HTTPS server
+        #
+        #server {
+        #    listen       443 ssl;
+        #    server_name  localhost;
+
+        #    ssl_certificate      cert.pem;
+       #    ssl_certificate_key  cert.key;
+
+        #    ssl_session_cache    shared:SSL:1m;
+        #    ssl_session_timeout  5m;
+
+        #    ssl_ciphers  HIGH:!aNULL:!MD5;
+        #    ssl_prefer_server_ciphers  on;
+
+        #    location / {
+        #        root   html;
+        #        index  index.html index.htm;
+        #    }
+        #}
+
+    }
+    rtmp {
+        server {
+            listen 1935;
+            application pullfromwowza {
+               live on;
+               pull rtmp://{{ .Values.remote_ip }}:1935/live;
+            }
+            application pullfromlocal {
+               live on;
+               play /opt/cdn/movies;
+            }
+        }
+    }
\ No newline at end of file
diff --git a/mcord/mcord-cdn-local/templates/nginx.yaml b/mcord/mcord-cdn-local/templates/nginx.yaml
new file mode 100644
index 0000000..aed0f95
--- /dev/null
+++ b/mcord/mcord-cdn-local/templates/nginx.yaml
@@ -0,0 +1,107 @@
+---
+# Copyright 2018-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: "node2"
+      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/mcord-cdn-local/values.yaml b/mcord/mcord-cdn-local/values.yaml
new file mode 100644
index 0000000..09a5354
--- /dev/null
+++ b/mcord/mcord-cdn-local/values.yaml
@@ -0,0 +1,31 @@
+---
+# Copyright 2018-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: epc
+nginx_hostname: "nginx"
+local_vlc_hostname: "local_vlc"
+# need to be changed to appropriate wowza server outside edge -- we can use the option --set remote_ip when deploying
+remote_ip: 10.10.10.10
+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"
+  ports:
+    rtmp_orig: 1935
+    rtmp_np: 31935
+  replicas: 1
diff --git a/mcord/mcord-cdn-remote/Chart.yaml b/mcord/mcord-cdn-remote/Chart.yaml
new file mode 100644
index 0000000..c6685a2
--- /dev/null
+++ b/mcord/mcord-cdn-remote/Chart.yaml
@@ -0,0 +1,21 @@
+---
+# 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
+appVersion: "1.0"
+description: A Helm chart for MCORD CDN Services in Remote cloud
+name: mcord-cdn-remote
+version: 0.1.1
diff --git a/mcord/mcord-cdn-remote/templates/cm.yaml b/mcord/mcord-cdn-remote/templates/cm.yaml
new file mode 100644
index 0000000..d2a098d
--- /dev/null
+++ b/mcord/mcord-cdn-remote/templates/cm.yaml
@@ -0,0 +1,24 @@
+---
+# Copyright 2018-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: wowza-config
+  namespace: {{ .Values.namespace }}
+data:
+  wowza_config.sh: |+
+    #!/bin/bash
+    echo "start"
\ No newline at end of file
diff --git a/mcord/mcord-cdn-remote/templates/remote-vlc.yaml b/mcord/mcord-cdn-remote/templates/remote-vlc.yaml
new file mode 100644
index 0000000..b352bc1
--- /dev/null
+++ b/mcord/mcord-cdn-remote/templates/remote-vlc.yaml
@@ -0,0 +1,74 @@
+---
+# Copyright 2018-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-vlc
+spec:
+  selector:
+    app: remote-vlc
+  clusterIP: None
+  ports:
+  - name: vlc
+    port: {{ .Values.remote_vlc.ports.vlc }}
+    protocol: TCP
+  - name: http
+    port: {{ .Values.remote_vlc.ports.http }}
+    protocol: TCP
+
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: remote-vlc
+  namespace: {{ .Values.namespace }}
+  labels:
+    name: remote-vlc
+    app: remote-vlc
+spec:
+  replicas: {{ .Values.remote_vlc.replicas }}
+  selector:
+    matchLabels:
+      app: remote-vlc
+  serviceName: "remote-vlc"
+  template:
+    metadata:
+      labels:
+        app: remote-vlc
+        name: remote-vlc
+    spec:
+      hostNetwork: true
+      terminationGracePeriodSeconds: 1
+      nodeSelector:
+        remote-vlc: remote-vlc
+      containers:
+      - name: streaming
+        image: {{ .Values.remote_vlc.images.remote_vlc_image }}
+        imagePullPolicy: IfNotPresent
+        ports:
+        - containerPort: {{ .Values.remote_vlc.ports.vlc }}
+        - containerPort: {{ .Values.remote_vlc.ports.http }}
+        stdin: true
+        tty: true
+        command: [ "bash",  "-xc"]
+        args:
+        - sed -i 's/geteuid/getppid/' /usr/bin/vlc;
+           cvlc larva_360p.mp4 --sout "#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100}:rtp{dst=0.0.0.0,port={{ .Values.remote_vlc.ports.vlc }},mux=ts,sap,name=Test}" --sout-keep --loop --ttl 10 --mtu 1200;
+        resources:
+          limits:
+            cpu: {{ .Values.remote_vlc.resources.cpu }}
+            memory: {{ .Values.remote_vlc.resources.mem }}
\ No newline at end of file
diff --git a/mcord/mcord-cdn-remote/templates/wowza.yaml b/mcord/mcord-cdn-remote/templates/wowza.yaml
new file mode 100644
index 0000000..4db08ed
--- /dev/null
+++ b/mcord/mcord-cdn-remote/templates/wowza.yaml
@@ -0,0 +1,119 @@
+---
+# Copyright 2018-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: wowza
+spec:
+  selector:
+    app: wowza
+  clusterIP: None
+  ports:
+    - name: rtmp-port
+      protocol: TCP
+      port: {{ .Values.wowza.ports.rtmp }}
+    - name: streammanager-port
+      protocol: TCP
+      port: {{ .Values.wowza.ports.streammanager }}
+    - name: rest-port
+      protocol: TCP
+      port: {{ .Values.wowza.ports.rest }}
+    - name: webui-port
+      protocol: TCP
+      port: {{ .Values.wowza.ports.webui }}
+
+---
+apiVersion: apps/v1beta1
+kind: StatefulSet
+metadata:
+  name: wowza
+  namespace: {{ .Values.namespace }}
+spec:
+  serviceName: wowza
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        name: wowza
+        app: wowza
+    spec:
+      hostNetwork: true
+      terminationGracePeriodSeconds: 0
+      imagePullSecrets:
+      - name: nexus-docker-secret
+      nodeSelector:
+        wowza: wowza
+      initContainers:
+      - name: "wowza-init"
+        image: {{ .Values.wowza.images.wowza_image }}
+        imagePullPolicy: IfNotPresent
+        args:
+        - cp /config/*.sh /shared-vol
+        command:
+        - "/bin/bash"
+        - "-c"
+        volumeMounts:
+        - name: "shared-volume"
+          mountPath: "/shared-vol"
+        - name: "wowza-conf"
+          mountPath: "/config"
+      containers:
+      - name: wowza
+        image: {{ .Values.wowza.images.wowza_image }}
+        imagePullPolicy: IfNotPresent
+        args:
+        - chmod a+x /config/*.sh;/config/wowza_config.sh;/sbin/entrypoint.sh
+        command:
+        - "/bin/bash"
+        - "-c"
+        tty: true
+        securityContext:
+          privileged: true
+        env:
+        - name: WSE_MGR_USER
+          value: wowza
+        - name: WSE_MGR_PASS
+          value: wowza
+        - name: WSE_LIC
+          value: ET1E4-bze6X-EpP8Z-EF3ZQ-ABhdM-hrJDZ-8bG9dcbA9Hkm
+        - name: WSE_IP_PARAM
+          valueFrom:
+            fieldRef:
+              fieldPath: spec.nodeName
+        ports:
+        - containerPort: {{ .Values.wowza.ports.rtmp }}
+        - containerPort: {{ .Values.wowza.ports.streammanager }}
+        - containerPort: {{ .Values.wowza.ports.rest }}
+        - containerPort: {{ .Values.wowza.ports.webui }}
+        volumeMounts:
+        - name: wowza-logs
+          mountPath: /usr/local/WowzaStreamingEngine/logs
+          readOnly: false
+        - name: shared-volume
+          mountPath: /config
+      volumes:
+      - name: wowza-logs
+        hostPath:
+          path: /var/log
+      - name: wowza-conf
+        configMap:
+          name: wowza-config
+          items:
+          - key: wowza_config.sh
+            path: wowza_config.sh
+      - name: shared-volume
+        emptyDir: {}
diff --git a/mcord/mcord-cdn-remote/values.yaml b/mcord/mcord-cdn-remote/values.yaml
new file mode 100644
index 0000000..aff0755
--- /dev/null
+++ b/mcord/mcord-cdn-remote/values.yaml
@@ -0,0 +1,40 @@
+---
+# Copyright 2018-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: wowz
+wowza_hostname: "wowza"
+remote_vlc_hostname: "remote-vlc"
+
+wowza:
+  images:
+    wowza_image: "10.90.0.131:30500/wowza:latest"
+  ports:
+    rtmp: 1935
+    streammanager: 8086
+    rest: 8087
+    webui: 8088
+  replicas: 1
+
+remote_vlc:
+  images:
+    init: "ngick8stesting/c3po-mmeinit"
+    remote_vlc_image: "woojoong/mwc-cdn:remote"
+  ports:
+    vlc: 8089
+    http: 50001
+  replicas: 1
+  resources:
+    cpu: 3
+    mem: "1Gi"
\ No newline at end of file