Hi! I am currently working on a Proof of Concept ...
# prefect-kubernetes
w
Hi! I am currently working on a Proof of Concept (PoC) with flows in Kubernetes. My aim is to run subflows in parallel. I have gone through a few examples using 'submit_to_runner' but I have not been able to make it work. Can someone help me identify what is wrong, or suggest another approach that I could follow? The configs are on thread 🧵 to not blowed this channel
Copy code
File "/usr/local/lib/python3.11/site-packages/prefect/runner/submit.py", line 162, in submit_to_runner
    raise RuntimeError(
RuntimeError: Failed to connect to the `Runner` webserver. Ensure that the server is running and reachable. You can run the webserver either by starting your `serve` process with `webserver=True`, or by setting `PREFECT_RUNNER_SERVER_ENABLE=True`.
This is my worker config:
Copy code
worker:
  image:
    pullPolicy: Always
    debug: true
  apiConfig: server
  config:
    workPool: k8s-local
  serverApiConfig:
    apiUrl: https://<my_self_hosted_prefect_server>/api

  extraEnvVars:
    - name: PREFECT_RUNNER_SERVER_ENABLE
      value: "true"
    - name: PREFECT_EXPERIMENTAL_ENABLE_EXTRA_RUNNER_ENDPOINTS
      value: "true"
This is my flow code:
Copy code
@flow
def subflow(value):
    logger = get_run_logger()
    logger.info(f"Subflow: {value}.")
    logger.info(f"Network: {platform.node()}.")
    logger.info(f"Instance: {platform.platform()}.")


@flow
def hello(name: str = "Marvin"):
    logger = get_run_logger()
    logger.info(os.environ)
    logger.info(f"Network: {platform.node()}.")
    logger.info(f"Instance: {platform.platform()}.")

    subflow("First")
    submit_to_runner(subflow, [{"value": f"submitted_subflow {i}"} for i in range(10)])

if __name__ == "__main__":
    with tags("local"):
        hello.serve("simulate-work", webserver=True, limit=10)
Flow results
Copy code
Finished in state Failed(message='Flow run encountered an exception. RuntimeError: Failed to connect to the `Runner` webserver. Ensure that the server is running and reachable. You can run the webserver either by starting your `serve` process with `webserver=True`, or by setting `PREFECT_RUNNER_SERVER_ENABLE=True`.', type=FAILED, result=UnpersistedResult(type='unpersisted', artifact_type='result', artifact_description='Unpersisted result of type `RuntimeError`'))
n
hi @William Jamir - the code makes sense to me my main suspicion is about the
host
and
port
of your runner webserver, are those defaults going to work for your k8s setup? here's a working example (docker compose) if its a useful reference
w
Sorry what do you mean by host and port of runner webserver, are you referring to
apiUrl
? or the
PREFECT_RUNNER_SERVER_HOST
? Btw I just added
Copy code
- name: PREFECT_RUNNER_SERVER_HOST
  value: "127.0.0.1"
But didn't worked as well =/