Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When creating a cronjob, Reference an existing job #81329

mouyang opened this issue Aug 13, 2019 · 1 comment


Copy link

commented Aug 13, 2019

What would you like to be added:

An ad-hoc run of a cronjob can be triggered by using the kubectl job --from=<cronjob>. The inverse operation should be available as well:

Sample Command Line: kubectl create cronjob --from-job=<job>

Sample YAML definition:

apiVersion: batch/v1beta1
kind: CronJob
  name: hello
  schedule: "*/1 * * * *"
    name: <JobTemplateSource>

Why is this needed:

Usability from multiple perspectives:

  • For unit testing, it is more intuitive to verify a job works standalone before putting it on a cronjob schedule.
  • The domain model suggested by the current functionality feels inverted. A job does not have to be connected to a cronjob in order to exist, but a cronjob can't exist without a job.
  • For a command-line user unaware of the existing functionality, in order to test the job they would need to either wait a potentially long time for a scheduled run, or overwrite the schedule in the cronjob spec using Helm or other means. Even if they knew about it, it is a very roundabout way of doing a simple task.
  • For a Dashboard user, the only way to unit test a job defined within a cronjob is to trigger it manually from a cronjob. Since there is an clear "Trigger" link in the Dashboard, this gives the impression that a manually triggered job from a cronjob will be cleaned up automatically as per the (successful/failed)JobsHistoryLimit when (I personally agree with this) it is not.

This comment has been minimized.

Copy link

commented Aug 13, 2019

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli and removed needs-sig labels Aug 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.