summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-02-18 17:44:07 +0100
committerChristian Pointner <equinox@spreadspace.org>2018-02-18 17:44:07 +0100
commit3e87f673bd262f7808c1fac7b0f853cab71a098d (patch)
tree71e7fd1d04b16fcb2185ec3615a0d10f89603f35 /src
parentadded k8s based stats (diff)
revamp handling of sfive proxy
Diffstat (limited to 'src')
-rw-r--r--src/examples/elevate2018.yml7
-rwxr-xr-xsrc/flufigut.py77
2 files changed, 52 insertions, 32 deletions
diff --git a/src/examples/elevate2018.yml b/src/examples/elevate2018.yml
index 443df97..4d8b7be 100644
--- a/src/examples/elevate2018.yml
+++ b/src/examples/elevate2018.yml
@@ -12,10 +12,11 @@ globals:
username: equinox
password: change-me
stats:
- sfive-proxy:
+ sfive:
socket: "/srv/hub.sock"
duration: 15s
tags: [ "elevate", "2018", "discourse" ]
+ type: proxy
resolutions:
1080p25: { width: 1920, height: 1080, rate: 25/1 }
720p25: { width: 1280, height: 720, rate: 25/1 }
@@ -57,6 +58,7 @@ globals:
flumotion_image_version: 12
nginx_image_version: 4
sfive_image_version: 2
+ onion_service_image_version: 3
inputs:
sdi-orig:
type: decklink
@@ -92,7 +94,6 @@ streams:
type: http
count: 1
port: 8000
- nginx-port: 8000
max-con: 100
burst-on-connect: 5
hostname: elevate-feed.spreadspace.org
@@ -102,11 +103,11 @@ streams:
type: http
count: 4
port: 8000
- nginx-port: 8000
max-bw: 290000000
burst-on-connect: 5
hostname: "emc-%02i.spreadspace.org"
repeater: True
+ onion-service: True
records:
av:
mux: avr
diff --git a/src/flufigut.py b/src/flufigut.py
index 1be9ffd..366c13e 100755
--- a/src/flufigut.py
+++ b/src/flufigut.py
@@ -494,7 +494,7 @@ class Planet:
self.flow['streamers'][comp_name]['plugs']['rrd']['bytes'] = "%s/%s_bytes.rrd" % (
self._desc.globals['stats']['rrd']['directory'], comp_name)
- if 'sfive' in self._desc.globals['stats']:
+ if 'sfive' in self._desc.globals['stats'] and self._desc.globals['stats']['sfive']['type'] == 'flumotion-plug':
self.flow['streamers'][comp_name]['plugs']['sfive'] = {}
self.flow['streamers'][comp_name]['plugs']['sfive']['socket'] = self._desc.globals['stats']['sfive']['socket']
self.flow['streamers'][comp_name]['plugs']['sfive']['duration'] = self._desc.globals['stats']['sfive']['duration']
@@ -545,6 +545,8 @@ class Planet:
self.__add_worker_flag_exclusive(worker, "stream", stream_name)
self.__add_worker_flag_exclusive(worker, "stream-hostname", hostname)
self.__add_worker_flag_exclusive(worker, "stream-index", idx)
+ if 'sfive' in self._desc.globals['stats']:
+ self.__add_worker_flag_exclusive(worker, "sfive", self._desc.globals['stats']['sfive']['type'])
def __generate_stream_instance(self, stream_name, stream, idx, cnt):
port = stream['port']
@@ -620,10 +622,44 @@ class Planet:
out += "%s:%s\n" % (worker['name'], crypt.crypt(worker['password'], salt))
return out.encode('utf-8')
+ def sfive_proxy_config(self, worker_name, for_onion=False):
+ # TODO: hardcoded values
+ hostname_prefix = "streamer"
+ addr = ""
+ port = 8000
+ if for_onion:
+ hostname_prefix = "streamer-onion"
+ addr = "127.0.0.1"
+ port = 8001
+
+ listen = "%s:%i" % (addr, port)
+ hostname = "%s-%s%d" % (hostname_prefix, self.workers[worker_name]['flags']['stream'], (self.workers[worker_name]['flags']['stream-index'] + 1))
+
+ conf = {'listen': listen, 'protocol': 'http'}
+ conf['connect'] = 'http://flumotion-worker-' + self.workers[worker_name]['name'] + ':8000'
+ conf['request_header'] = [{'op': 'del', 'header': 'X-Forwarded-For'}]
+ conf['response_header'] = [{'op': 'set', 'header': 'Cache-Control', 'value': 'no-cache'},
+ {'op': 'add', 'header': 'Cache-Control', 'value': 'no-store'},
+ {'op': 'add', 'header': 'Cache-Control', 'value': 'must-revalidate'},
+ {'op': 'add', 'header': 'Cache-Control', 'value': 'max-age=0'},
+ {'op': 'time', 'header': 'Expires', 'value': '-1s'}]
+ conf['backends'] = {}
+ conf['backends']['/hls/'] = {'connect': 'http://nginx-streamer-' + self.workers[worker_name]['name'] + ':8000'}
+ conf['backends']['/dash/'] = {'connect': 'http://nginx-streamer-' + self.workers[worker_name]['name'] + ':8000'}
+
+ conf['sfive'] = {'hostname': hostname}
+ conf['sfive']['socket'] = self._desc.globals['stats']['sfive']['socket']
+ conf['sfive']['duration'] = self._desc.globals['stats']['sfive']['duration']
+ conf['sfive']['tags'] = self._desc.globals['stats']['sfive']['tags']
+ conf['sfive']['matches'] = [{'format': '/${content}-${format}-${quality}', 'streams': 'av-orig/flash,webm/high,medium,low,mini'},
+ {'format': '/${format}/${content}-${quality}', 'streams': 'av-orig/dash,hls/high,medium,low,mini'}]
+
+ return conf
# kubernetes handling #############################
#
+
class K8sDeployment:
def __init__(self, desc, planet, namespace=None):
@@ -703,38 +739,21 @@ class K8sDeployment:
appsV1.create_namespaced_deployment(self._namespace, deploy)
def _deploy_sfive_worker(self, template_dir, tmpl_env, v1, appsV1, worker):
- needs_sfive = False
- if 'sfive-proxy' in self._desc.globals['stats'] and 'stream' in worker['flags']:
- needs_sfive = True
-
- if not needs_sfive:
+ if 'sfive' not in worker['flags']:
return
- # TODO: hardcoded values
- proxy_conf = {'listen': ':8000', 'protocol': 'http'}
- proxy_conf['connect'] = 'http://flumotion-worker-' + worker['name'] + ':8000'
- proxy_conf['request_header'] = [{'op': 'del', 'header': 'X-Forwarded-For'}]
- proxy_conf['response_header'] = [{'op': 'set', 'header': 'Cache-Control', 'value': 'no-cache'},
- {'op': 'add', 'header': 'Cache-Control', 'value': 'no-store'},
- {'op': 'add', 'header': 'Cache-Control', 'value': 'must-revalidate'},
- {'op': 'add', 'header': 'Cache-Control', 'value': 'max-age=0'},
- {'op': 'time', 'header': 'Expires', 'value': '-1s'}]
- proxy_conf['backends'] = {}
- proxy_conf['backends']['/hls/'] = {'connect': 'http://nginx-streamer-' + worker['name'] + ':8000'}
- proxy_conf['backends']['/dash/'] = {'connect': 'http://nginx-streamer-' + worker['name'] + ':8000'}
-
- proxy_conf['sfive'] = {'hostname': "streamer-%s%d" % (worker['flags']['stream'], (worker['flags']['stream-index'] + 1))}
- proxy_conf['sfive']['socket'] = self._desc.globals['stats']['sfive-proxy']['socket']
- proxy_conf['sfive']['duration'] = self._desc.globals['stats']['sfive-proxy']['duration']
- proxy_conf['sfive']['tags'] = self._desc.globals['stats']['sfive-proxy']['tags']
- proxy_conf['sfive']['matches'] = [{'format': '/${content}-${format}-${quality}', 'streams': 'av-orig/flash,webm/high,medium,low,mini'},
- {'format': '/${format}/${content}-${quality}', 'streams': 'av-orig/dash,hls/high,medium,low,mini'}]
-
- cm = self.__generate_object(tmpl_env, 'sfive-proxy-cm.yml', worker)
- cm['data']['proxy.json'] = json.dumps(proxy_conf)
+ cm = self.__generate_object(tmpl_env, 'sfive-cm.yml', worker)
+ if 'data' not in cm or not cm['data']:
+ cm['data'] = {}
+ if worker['flags']['sfive'] == 'proxy' and 'stream' in worker['flags']:
+ cm['data']['proxy.json'] = json.dumps(self._planet.sfive_proxy_config(worker['name']))
+ stream_name = worker['flags']['stream']
+ if 'onion-service' in self._desc.streams[stream_name] and len(self._desc.streams[stream_name]['nginx-muxes']) > 0:
+ cm['data']['proxy-onion.json'] = json.dumps(self._planet.sfive_proxy_config(worker['name'], True))
+
v1.create_namespaced_config_map(self._namespace, cm)
- deploy = self.__generate_object(tmpl_env, 'sfive-proxy-deploy.yml', worker)
+ deploy = self.__generate_object(tmpl_env, 'sfive-deploy.yml', worker)
appsV1.create_namespaced_deployment(self._namespace, deploy)
def deploy(self, template_dir):