https://prefect.io logo
Title
c

Christian Nuss

03/03/2022, 4:51 PM
anyone have a lil cheatsheet snippet for a
KubernetesRun
defininig the
job_template
as a dict?
k

Kevin Kho

03/03/2022, 5:10 PM
I haven’t seen any but you can replicate it if you have a job_template_path already by coping this code
job
is a dict there
c

Christian Nuss

03/03/2022, 5:12 PM
nice thanks, it will do a bit of merging it appears?
k

Kevin Kho

03/03/2022, 5:16 PM
the merging is agent settings and run config settings cuz run config will overwrite
c

Christian Nuss

03/03/2022, 5:46 PM
interesting... i tried this, but my label didn't show up
return KubernetesRun(
            labels=labels,
            env=app_settings_dict,
            image=app_settings.PREFECT_WORKFLOWS_CONTAINER,
            image_pull_policy="IfNotPresent",
            job_template={
                "apiVersion": "batch/v1",
                "kind": "Job",
                "spec": {
                    "template": {
                        "spec": {
                            "labels": {
                                "foo": "test123"
                            },
                            "containers": [
                                {
                                    "name": "flow"
                                }
                            ]
                        }
                    }
                }
            }
        )
k

Kevin Kho

03/03/2022, 5:49 PM
I think labels should go on the RunConfig, not the job template right? Or are those not Prefect labels?
c

Christian Nuss

03/03/2022, 8:16 PM
i'm doing an experiment on how i can augment the launch of the pod/job/container, i need to enrich it a tad with some volume mounts and network config for launching on docker mac + kube
the code link you sent me was helpful to figure that out! thank you!
i'll share what i finally get to, maybe it can be added to docs
k

Kevin Kho

03/03/2022, 8:21 PM
Yes feel free to do a PR
c

Christian Nuss

03/03/2022, 8:42 PM
got it, my data structure was wonky!
return KubernetesRun(
            labels=labels,
            env=app_settings_dict,
            image=app_settings.PREFECT_WORKFLOWS_CONTAINER,
            image_pull_policy="IfNotPresent",
            job_template={
                "apiVersion": "batch/v1",
                "kind": "Job",
                "spec": {
                    "template": {
                        "metadata": {
                            "labels": {
                                "foo": "test123"
                            }
                        },
                        "spec": {
                            "containers": [
                                {
                                    "name": "flow"
                                }
                            ]
                        }
                    }
                }
            }
        )
that applied a label to the job and the eventual pod
k

Kevin Kho

03/03/2022, 9:03 PM
Nice!
c

Christian Nuss

03/03/2022, 9:21 PM
k

Kevin Kho

03/03/2022, 9:25 PM
Thank you! The core team will see it