Guide for testing out KubernetesFlowRunner locally

Install Docker Desktop:

Start a Local Kubernetes Cluster:

In terminal screen #1

prefect kubernetes manifest orion | kubectl apply -f -
kubectl port-forward deployment/orion 4200:4200

In a separate terminal #2 (I like to use the command screen)

prefect work-queue create kubernetes-test  # use output from this
prefect agent start <UUID> # here

In separate terminal #3, copy this script in

from prefect import flow, task
from prefect.deployments import DeploymentSpec
from prefect.flow_runners import KubernetesFlowRunner

def helper():
    print('Hello from Kubernetes task!')

def my_kubernetes_flow():

    print('Hello from Kubernetes flow!')


Then run this in terminal #3

prefect deployment create
prefect deployment run my-kubernetes-flow/k8s-example
1 Like