Make service listing configurable
This commit is contained in:
parent
76c99bd568
commit
b962f2695c
@ -16,12 +16,15 @@ from sanic import Sanic, response
|
|||||||
from sanic.response import stream
|
from sanic.response import stream
|
||||||
from sanic_prometheus import monitor
|
from sanic_prometheus import monitor
|
||||||
|
|
||||||
|
SERVICE_NAMESPACE = os.getenv("SERVICE_NAMESPACE", "camtiler")
|
||||||
|
SERVICE_LABEL_SELECTOR = os.getenv("SERVICE_LABEL_SELECTOR", "component=camera-motion-detect")
|
||||||
|
|
||||||
targets = [(j,j) for j in sys.argv[1:]]
|
targets = [(j,j) for j in sys.argv[1:]]
|
||||||
if not targets:
|
if not targets:
|
||||||
# If no targets are specified, fall back to Kube API
|
# If no targets are specified, fall back to Kube API
|
||||||
config.load_incluster_config()
|
config.load_incluster_config()
|
||||||
v1 = client.CoreV1Api()
|
v1 = client.CoreV1Api()
|
||||||
for i in v1.list_namespaced_service("camtiler", label_selector="component=camdetect").items:
|
for i in v1.list_namespaced_service(SERVICE_NAMESPACE, label_selector=SERVICE_LABEL_SELETOR).items:
|
||||||
url = "http://%s:%d/bypass" % (i.metadata.name, i.spec.ports[0].port)
|
url = "http://%s:%d/bypass" % (i.metadata.name, i.spec.ports[0].port)
|
||||||
targets.append((i.metadata.name, url))
|
targets.append((i.metadata.name, url))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user