Skip to content

Added new Scheduled Jobs topic #3088

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

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion _topic_map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ Topics:
File: environment_variables
- Name: Jobs
File: jobs
- Name: Scheduled Jobs
File: scheduled_jobs
- Name: Revision History
File: revhistory_dev_guide
Distros: openshift-enterprise,openshift-dedicated
Expand Down Expand Up @@ -695,7 +697,7 @@ Topics:
- Name: Python
File: python
- Name: Ruby
File: ruby
File: ruby
- Name: Database Images
Dir: db_images
Topics:
Expand Down
25 changes: 8 additions & 17 deletions dev_guide/jobs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ xref:../architecture/core_concepts/deployments.adoc#replication-controllers[a
replication controller]), runs any number of pods to completion. A job tracks the
overall progress of a task and updates its status with information about active,
succeeded, and failed pods. Deleting a job will clean up any pods it created.
Jobs are part of the extensions Kubernetes API, which can be managed with `oc` commands like other
Jobs are part of the Kubernetes API, which can be managed with `oc` commands like other
xref:../cli_reference/basic_cli_operations.adoc#object-types[object types].

See the http://kubernetes.io/docs/user-guide/jobs/[Kubernetes documentation] for
more information about jobs.

[[creating-a-job]]

== Creating a Job

A job configuration consists of the following key parts:
Expand All @@ -41,21 +40,16 @@ The following is an example of a `*job*` resource:
====
[source,yaml]
----
apiVersion: extensions/v1beta1
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
selector: <1>
matchLabels:
app: pi
parallelism: 1 <2>
completions: 1 <3>
template: <4>
parallelism: 1 <1>
completions: 1 <2>
template: <3>
metadata:
name: pi
labels:
app: pi
spec:
containers:
- name: pi
Expand All @@ -64,15 +58,12 @@ spec:
restartPolicy: Never
----
1. Label selector of the pod to run. It uses the https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/labels.md#label-selectors[generalized label selectors].
2. Optional value for how many pods a job should run in parallel, defaults to `*completions*`.
3. Optional value for how many successful pod completions is needed to mark a job completed, defaults to one.
4. Template for the pod the controller creates.
1. Optional value for how many pods a job should run in parallel, defaults to `*completions*`.
2. Optional value for how many successful pod completions is needed to mark a job completed, defaults to one.
3. Template for the pod the controller creates.
====


[[scaling-a-job]]

== Scaling a Job

A job can be scaled up or down by using the `oc scale` command with `--replicas`
Expand Down
98 changes: 98 additions & 0 deletions dev_guide/scheduled_jobs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[[dev-guide-scheduled-jobs]]
= Scheduled Jobs
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:
:prewrap!:

toc::[]

== Overview

A _scheduled job_ builds on a regular
xref:../dev_guide/jobs.adoc#dev-guide-jobs[job] by allowing you to specifically
schedule how the job should be run. Scheduled jobs are part of the
link:http://kubernetes.io/docs/user-guide/scheduled-jobs[Kubernetes] API, which
can be managed with `oc` commands like other
xref:../cli_reference/basic_cli_operations.adoc#object-types[object types].

ifdef::openshift-enterprise[]
[NOTE]
====
As of {product-title} 3.3.1, Scheduled Jobs is a feature in Technology Preview.
====
endif::[]

[[creating-a-scheduledjob]]
== Creating a Scheduled Job

A scheduled job configuration consists of the following key parts:

* A schedule specified in link:https://en.wikipedia.org/wiki/Cron[cron format].
* A job template used when creating the next job.
* An optional deadline (in seconds) for starting the job if it misses its
scheduled time for any reason. Missed jobs executions will be counted as failed
ones. If not specified, there is no deadline.
* `*ConcurrencyPolicy*`: An optional concurrency policy, specifying how to treat
concurrent jobs within a scheduled job. Only one of the following concurrent
policies may be specified. If not specified, this defaults to allowing
concurrent executions.
** `Allow` allows Scheduled Jobs to run concurrently.
** `Forbid` forbids concurrent runs, skipping the next run if the previous has not
finished yet.
** `Replace` cancels the currently running job and replaces
it with a new one.
* An optional flag allowing the suspension of a scheduled job. If set to `true`,
all subsequent executions will be suspended.

The following is an example of a `*ScheduledJob*` resource:

====
[source,yaml]
----
apiVersion: batch/v2alpha1
kind: ScheduledJob
metadata:
name: pi
spec:
schedule: */1 * * * ? <1>
jobTemplate: <2>
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
----
1. Schedule for the job. In this example, a job will run every minute.
2. Job template. This is similar to the xref:../dev_guide/jobs.adoc#creating-a-job[job example].
====

ifdef::openshift-enterprise[]
[[scheduledjob-known-issues]]
== Known Issues

[[scheduledjob-known-issues-unable-to-edit]]
=== Unable to Edit a Scheduled Job

There is a link:https://bugzilla.redhat.com/show_bug.cgi?id=1378368[known issue]
when invoking `oc edit scheduledjob` due to an error that was already fixed in
the latest version. However, due to significant code changes, this was not
backported.

One possible solution is to use `oc patch` command instead of `oc edit`.

[[scheduledjob-known-issues-change-concurrency]]
=== Unable to Change Concurrency Policy

There is a link:https://bugzilla.redhat.com/show_bug.cgi?id=1386463[known issue]
when changing concurrency policy where no new jobs are created after that
operation is run. The issue is still under investigation in the latest version.
endif::[]