def main(): if operator_utils.NAMESPACED_OPERATOR: kwargs = {"namespaces": [operator_utils.OPERATOR_NAMESPACE]} else: kwargs = {"clusterwide": True} asyncio.run(kopf.operator(**kwargs))
def kopf_thread( ready_flag: threading.Event, stop_flag: threading.Event, ): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) kopf.configure(verbose=True) # log formatting loop.run_until_complete( kopf.operator( ready_flag=ready_flag, stop_flag=stop_flag, ))
def TriadControllerLoop( ready_flag: threading.Event, stop_flag: threading.Event, ): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) with contextlib.closing(loop): kopf.configure(verbose=False) # log formatting loop.set_exception_handler(HandleExceptions) loop.run_until_complete(kopf.operator( ready_flag=ready_flag, stop_flag=stop_flag, ))
def kopf_thread( ready_flag: threading.Event, stop_flag: threading.Event, ): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) with contextlib.closing(loop): kopf.configure(verbose=True) # log formatting loop.run_until_complete( kopf.operator( ready_flag=ready_flag, stop_flag=stop_flag, memo=kopf.Memo( create_tpl="Hello, {name}!", delete_tpl="Good bye, {name}!", ), ))
def kopf_thread( ready_flag: threading.Event, stop_flag: threading.Event, ): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) with contextlib.closing(loop): opts = { "liveness_endpoint": f"http://0.0.0.0:{sidecar_settings.HEALTHCHECK_PORT}/healthz", "clusterwide": False, "namespaces": [], "ready_flag": ready_flag, "stop_flag": stop_flag } if sidecar_settings.NAMESPACE == 'ALL': opts['clusterwide'] = True else: opts['namespaces'] = sidecar_settings.NAMESPACE loop.run_until_complete(kopf.operator(**opts))
def run_kopf(namespace): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(kopf.operator(standalone=True, namespace=namespace))