https://prefect.io logo
Title
m

Marcelo Santoro

12/20/2022, 3:13 PM
Hey Prefect community .... Does anyone knows if .... is there any way to rename the k8s prefect jobs ? because is really hard to identify what flow is running in each job šŸ˜•
šŸ‘€ 1
āœ… 1
b

Bianca Hoch

12/21/2022, 6:49 PM
Hi Marcelo, I believe you can modify the names of the k8s jobs by passing the name of the flow to the
name
variable in the base job template. Here a few resources to get your started: ā€¢ Creating and Deploying a custom Kubernetes Infrastructure Block ā€¢ Documentation for KubernetesJob (see
name
attribute) ā€¢ Additional documentation for KubernetesJob
When creating a custom infrastructure block, it may look something like this with the
name
set to your "prefect-flow-name".
from prefect.infrastructure import KubernetesJob

k8s_job=KubernetesJob(
    namespace="prefect2",
    name = "prefect-flow-name"
    image="prefecthq/prefect:2.3.0-python3.9",
    env={"EXTRA_PIP_PACKAGES": "adlfs"}
  job=KubernetesJob.job_from_file("modified_run_job.yaml")
)

k8s_job.save("k8sdev")
m

Marcelo Santoro

12/21/2022, 6:55 PM
Thank you so much @Bianca Hoch... I will give it a try šŸ™
cc: @Josh šŸ™‚
@Bianca Hoch I have a question, does this work in prefect 1 ?
b

Bianca Hoch

12/21/2022, 7:54 PM
Oh! For 1.0 that would be KubernetesRun I believe (which replaced KubernetesJobEnvironment). From what I understand, you can still modify the name that is specified for the job by changing it in the job template. Here's some more resources for you that should be helpful: ā€¢ https://docs-v1.prefect.io/api/latest/run_configs.html#kubernetesrun
šŸ™Œ 1
m

Marcelo Santoro

12/21/2022, 7:55 PM
Thank you very much šŸ™‚
b

Bianca Hoch

12/21/2022, 7:56 PM
And just for fun, here's an article that compares and contrasts how KubernetesRun and KubernetesJob compare. This will be useful for you when you begin to consider migrating to 2.0.
šŸ™Œ 1
šŸ‘ 1
āœ… 1