Пример #1
0
def main():
    if operator_utils.NAMESPACED_OPERATOR:
        kwargs = {"namespaces": [operator_utils.OPERATOR_NAMESPACE]}
    else:
        kwargs = {"clusterwide": True}

    asyncio.run(kopf.operator(**kwargs))
Пример #2
0
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,
        ))
Пример #3
0
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,
        ))
Пример #4
0
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}!",
                ),
            ))
Пример #5
0
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))
Пример #6
0
def run_kopf(namespace):
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    loop.run_until_complete(kopf.operator(standalone=True,
                                          namespace=namespace))