kuberay icon indicating copy to clipboard operation
kuberay copied to clipboard

[RayJob] Add `RayCronJob` Custom Resource Definition

Open architkulkarni opened this issue 3 years ago • 9 comments

Kubernetes has a built in CronJob resource. However, there's no clear way to hook it up to RayJob.

We should create a new CRD, RayCronJob, designed to mimic the behavior of Kubernetes' native CronJob resource. This new CRD would schedule and manage the execution of RayJobs at specific, regular intervals. The new RayCronJob resource should follow the same structure and conventions as Kubernetes' CronJob resource.

architkulkarni avatar Jun 28 '23 16:06 architkulkarni

Yes please!

elephantum avatar Jul 30 '23 21:07 elephantum

@architkulkarni I would like to work on this issue if no one has taken this up!

One way that I can think of to hook up CronJob with RayJob can be as follows:

  1. Create a python / go / any other script that uses the Kubernetes API to create a RayJob.
  2. Create a Docker image with this script.
  3. Then the CronJob can spawn a Pod running this container, which in turn would create a new RayJob.

I understand that this is not a clean way to handle this and also is not 'Kubernetes-native' approach to scheduling.

However, can this serve as temporary workaround for users till the CRD is implemented? In case someone visits this issue, they might use this?

Now for the actual CRD implementation, I understand that this might be a little tricky as my first issue, but still, I am very interested in this and would like to submit code changes for the same.

shubhscoder avatar Aug 02 '23 20:08 shubhscoder

@shubhscoder That sounds like a reasonable workaround, thanks for sharing it! I don't think we need to merge the workaround solution into the kuberay repo, but we'd welcome your contributions for the CRD implementation. Let us know if you have an idea for a design, and we can give you code pointers as needed.

cc @kevin85421 for awareness

architkulkarni avatar Aug 03 '23 20:08 architkulkarni

I don't think we should introduce a new RayCronJob CRD. A RayJob is simply a special case of a RayCronJob that runs only once and executes immediately. We do not need to have another CRD to increase our maintenance workload.

  • Solution 1: We can just do some minor changes in RayJob to achieve this.
  • Solution 2: As @shubhscoder suggested, users can define the repeat schedule for their RayJob within their applications using either the KubeRay Python client or the KubeRay API Server. With the KubeRay API Server, users can also deploy a Kubernetes CronJob to submit RayJob creation logic periodically.

I'd recommend going with solution 2. I can think of many edge cases that we would need to handle for solution 1, and the KubeRay maintainers may not have the bandwidth to manage them all. It would be better for users to define this logic at the application level.

kevin85421 avatar Aug 03 '23 21:08 kevin85421

@kevin85421 Yes, I think that is correct. In that case do you think we should add a small example on how we can achieve that functionality? I will also try to find some other issues to work on in the mean time, but @kevin85421 or @architkulkarni if you'll have any issues which could use some help, let me know, I would be happy to take them up! Thanks!

shubhscoder avatar Aug 04 '23 19:08 shubhscoder

@shubhscoder, I discussed offline with @kevin85421 and we think it would be a great idea to have a docs example on solution 2 with the KubeRay API server, if you're willing to contribute this that would be great!

Some other good first issues could be:

  • https://github.com/ray-project/kuberay/issues/1266
  • https://github.com/ray-project/kuberay/issues/1195

architkulkarni avatar Aug 04 '23 20:08 architkulkarni

@architkulkarni Thanks for your input! I would be more than happy to contribute the docs example!

Thanks for pointing out other issues as well! I will take a look at them!

shubhscoder avatar Aug 04 '23 20:08 shubhscoder

#1291 is also a good first issue.

kevin85421 avatar Aug 04 '23 21:08 kevin85421

This issue has been automatically marked as stale because it has not had any activity for 120 days. It will be closed in 14 days if no further activity occurs.

If you'd like to keep this issue open, just leave any comment, and the stale label will be removed. If you'd like to get more attention on this issue, please tag one of the KubeRay maintainers.

You can always ask for help on Ray's public Slack channel.

github-actions[bot] avatar Sep 21 '26 18:09 github-actions[bot]