anyone have a lil cheatsheet snippet for a `Kubern...
# prefect-community
c
anyone have a lil cheatsheet snippet for a
KubernetesRun
defininig the
job_template
as a dict?
k
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
nice thanks, it will do a bit of merging it appears?
k
the merging is agent settings and run config settings cuz run config will overwrite
c
interesting... i tried this, but my label didn't show up
Copy code
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
I think labels should go on the RunConfig, not the job template right? Or are those not Prefect labels?
c
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
Yes feel free to do a PR
c
got it, my data structure was wonky!
Copy code
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
Nice!
c
k
Thank you! The core team will see it