EDGEPOD-114 Enhance CDN-local to better support of hostNetwork
Also renamed resouce names from nginx to cdn-local.
Change-Id: Ib77f18b8e8ea2efcb73c0d36a621bdee5eea2f33
diff --git a/ott-services/cdn-local/Chart.yaml b/ott-services/cdn-local/Chart.yaml
index 7e56dda..05a457d 100644
--- a/ott-services/cdn-local/Chart.yaml
+++ b/ott-services/cdn-local/Chart.yaml
@@ -14,7 +14,7 @@
# limitations under the License.
apiVersion: v1
-appVersion: "1.0"
description: A Helm chart for M-CORD CDN Services in Local Edge
+icon: https://guide.opencord.org/logos/cord.svg
name: cdn-local
-version: 0.2.3
+version: 0.2.4
diff --git a/ott-services/cdn-local/templates/bin/_network-config.sh.tpl b/ott-services/cdn-local/templates/bin/_network-config.sh.tpl
deleted file mode 100644
index 9402049..0000000
--- a/ott-services/cdn-local/templates/bin/_network-config.sh.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/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
deleted file mode 100644
index 7dcea6c..0000000
--- a/ott-services/cdn-local/templates/bin/_route-gen.sh.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/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
index cde099e..ffe7916 100644
--- a/ott-services/cdn-local/templates/bin/_run-nginx.sh.tpl
+++ b/ott-services/cdn-local/templates/bin/_run-nginx.sh.tpl
@@ -14,5 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# Assume that SGI network gateway knows routes to UE pool
+{{- if .Values.config.sriov.enabled }}
+ip route add {{ .Values.networks.ue.subnet }} via {{ .Values.networks.sgi.gateway }}
+{{- end }}
+
+ip link set {{ .Values.config.nginx.sgiInterface.name }} mtu {{ .Values.config.nginx.sgiInterface.mtu }}
+
cp /conf/nginx.conf /etc/nginx/
-nginx -g "daemon off;"
\ No newline at end of file
+nginx -g "daemon off;"
diff --git a/ott-services/cdn-local/templates/configmap-nginx.yaml b/ott-services/cdn-local/templates/configmap-nginx.yaml
index 1e505bd..75db4d6 100644
--- a/ott-services/cdn-local/templates/configmap-nginx.yaml
+++ b/ott-services/cdn-local/templates/configmap-nginx.yaml
@@ -22,10 +22,6 @@
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 }}
@@ -95,4 +91,4 @@
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
index b3bf674..be315f8 100644
--- a/ott-services/cdn-local/templates/networks.yaml
+++ b/ott-services/cdn-local/templates/networks.yaml
@@ -29,4 +29,4 @@
"type": {{ .Values.networks.ipam | quote }}
}
}'
-{{ end }}
\ No newline at end of file
+{{ end }}
diff --git a/ott-services/cdn-local/templates/service-nginx.yaml b/ott-services/cdn-local/templates/service-nginx.yaml
index a0422b4..448f1ae 100644
--- a/ott-services/cdn-local/templates/service-nginx.yaml
+++ b/ott-services/cdn-local/templates/service-nginx.yaml
@@ -18,12 +18,12 @@
apiVersion: v1
kind: Service
metadata:
- name: nginx
+ name: cdn-local
labels:
-{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+{{ tuple "cdn-local" . | include "cdn-local.metadata_labels" | indent 4 }}
spec:
selector:
-{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+{{ tuple "cdn-local" . | include "cdn-local.metadata_labels" | indent 4 }}
ports:
- name: http
port: {{ .Values.config.nginx.ports.http }}
@@ -36,12 +36,12 @@
apiVersion: v1
kind: Service
metadata:
- name: nginx-external
+ name: cdn-local-external
labels:
-{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+{{ tuple "cdn-local" . | include "cdn-local.metadata_labels" | indent 4 }}
spec:
selector:
-{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+{{ tuple "cdn-local" . | include "cdn-local.metadata_labels" | indent 4 }}
type: NodePort
ports:
- name: http
@@ -51,4 +51,4 @@
- name: rtmp
port: {{ .Values.config.nginx.ports.rtmp }}
protocol: TCP
- nodePort: {{ .Values.config.nginx.ports.nodePorts.rtmp }}
\ No newline at end of file
+ nodePort: {{ .Values.config.nginx.ports.nodePorts.rtmp }}
diff --git a/ott-services/cdn-local/templates/statefulset-nginx.yaml b/ott-services/cdn-local/templates/statefulset-cdn-local.yaml
similarity index 82%
rename from ott-services/cdn-local/templates/statefulset-nginx.yaml
rename to ott-services/cdn-local/templates/statefulset-cdn-local.yaml
index 9eaa5b0..3937078 100644
--- a/ott-services/cdn-local/templates/statefulset-nginx.yaml
+++ b/ott-services/cdn-local/templates/statefulset-cdn-local.yaml
@@ -14,32 +14,32 @@
limitations under the License.
*/}}
-{{ tuple "nginx" . | include "cdn-local.service_account" }}
+{{ tuple "cdn-local" . | include "cdn-local.service_account" }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
- name: nginx
+ name: cdn-local
labels:
-{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 4 }}
+{{ tuple "cdn-local" . | 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"
+{{ tuple "cdn-local" . | include "cdn-local.metadata_labels" | indent 6 }}
+ serviceName: "cdn-local"
template:
metadata:
labels:
-{{ tuple "nginx" . | include "cdn-local.metadata_labels" | indent 8 }}
+{{ tuple "cdn-local" . | 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 }}
+ "interface": {{ .Values.config.nginx.sgiInterface.name | quote }},
+ "ips": {{ .Values.config.nginx.sgiInterface.ip | quote }}
}
]'
{{ end }}
@@ -49,9 +49,9 @@
{{ .Values.nodeSelectors.nginx.label }}: {{ .Values.nodeSelectors.nginx.value }}
{{- end }}
hostNetwork: {{ not .Values.config.sriov.enabled }}
- serviceAccountName: nginx
+ serviceAccountName: cdn-local
initContainers:
- - name: nginx-init
+ - name: cdn-local-init
image: {{ .Values.images.tags.nginx }}
imagePullPolicy: {{ .Values.images.pullPolicy }}
securityContext:
@@ -74,7 +74,7 @@
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
+ - chmod a+x /config/*.sh; /config/run-nginx.sh
securityContext:
privileged: true
volumeMounts:
@@ -107,4 +107,4 @@
name: nginx-rtmp-config
defaultMode: 420
- name: shared-volume
- emptyDir: {}
\ No newline at end of file
+ emptyDir: {}
diff --git a/ott-services/cdn-local/values.yaml b/ott-services/cdn-local/values.yaml
index 6f6e675..558600b 100644
--- a/ott-services/cdn-local/values.yaml
+++ b/ott-services/cdn-local/values.yaml
@@ -51,10 +51,14 @@
enabled: true
rtmp: 31935
http: 31885
- sgi:
- device: sgi-net-cdn
- ip: 13.1.1.253/24
- mtu: 1200
+ # In case sriov is enabled, additional interface connected to sgi-network directly will be added
+ # with the name and address specified below.
+ # Otherwise, specify the interface name connected to SGI network in the host machine.
+ # IP address will be ignored in that case.
+ sgiInterface:
+ name: sgi-net-cdn
+ mtu: 1200
+ ip: 192.168.250.249/24
events:
workerProcesses: 1
workerConnections: 1024
@@ -101,18 +105,13 @@
# 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
+ subnet: 192.168.250.0/24
mask: 255.255.255.0
- gateway: 13.1.1.254
+ gateway: 192.168.250.250
+ ue:
+ subnet: 10.250.0.0/16