Hi, I have the following code: ```import prefect f...
# ask-community
t
Hi, I have the following code:
Copy code
import prefect
from prefect import Flow, task
from prefect.tasks.kubernetes.job import RunNamespacedJob


start_body = {
    "apiVersion": "batch/v1",
    "kind": "Job",
    "metadata": {
        "name": "start"
    },
    "spec": {
        "template": {
            "spec": {
                "containers": [
                    {
                        "name": "start",
                        "image": "alpine",
                        "command": [
                            "echo",
                            "start"
                        ]
                    }
                ],
                "restartPolicy": "Never"
            }
        },
        "backoffLimit": 4
    }
}

@task
def print_kube_res(x):
    print(str(x))

with Flow("Kubernetes Job") as flow:
    start = RunNamespacedJob(body=start_body, kubernetes_api_key_secret=None)
    p = print_kube_res(start)
    start.set_downstream(p)
But here the print task prints 'None'. How do i get the result from a Kubernetes job ?
k
Hi @thebuleon29, in this case, do you want to retrieve the “start”? I don’t think this task is meant for that. You would probably need to persist the output somewhere and retrieve it by downstream tasks.