https://prefect.io logo
Title
s

Sylvain Hazard

12/21/2021, 10:59 AM
Hello ! I'm not really that fluent in Kubernetes so I figured I should ask here : would a RunNamespacedJob task work for launching CronJobs on my cluster ? I understand that does not necessarily make sense but I'd like to know if it would work 🙂
d

davzucky

12/21/2021, 11:18 AM
We are using that to kick off our job in K8s. This replace the usage of cronjob. What is good is that perfect give you inside about the job
a

Anna Geller

12/21/2021, 11:21 AM
@davzucky can you share more how you did it? I was just about to write that it doesn’t seem possible because this task seems to expect “Job” kind rather than CronJob, but maybe it’s more nuanced
d

davzucky

12/21/2021, 11:29 AM
Sure. We are generating our K8s job configuration in our flow and pass it to the Bodie parameter. The job configuration is the same we had with the cronjob. We are using that to kick off spark-summit inside of kubernetes. However if the question is about starting a cronjob manually from perfect the answer is no.
:upvote: 2
a

Anna Geller

12/21/2021, 11:39 AM
@Sylvain Hazard a formality really but here is a confirmation that you can’ use anything different than kind: Job with this task, including CronJob:
kubernetes.client.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'cdf51873-6674-4563-8a90-8a6c7da1c979', 'X-Kubernetes-Pf-Prioritylevel-Uid': 'e007fab6-71ca-46cb-a2a8-f128b61e6873', 'Date': 'Tue, 21 Dec 2021 11:37:58 GMT', 'Content-Length': '227'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"CronJob in version \"v1\" cannot be handled as a Job: converting (v1.CronJob) to (batch.Job): unknown conversion","reason":"BadRequest","code":400}
s

Sylvain Hazard

12/22/2021, 7:01 AM
Thanks to both of you for the answers, I really appreciate !