Skip to content

Commit adb7385

Browse files
soltyshahardin-rh
authored andcommitted
Added new Scheduled Jobs topic
1 parent a413070 commit adb7385

File tree

3 files changed

+109
-18
lines changed

3 files changed

+109
-18
lines changed

Diff for: _topic_map.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ Topics:
641641
File: environment_variables
642642
- Name: Jobs
643643
File: jobs
644+
- Name: Scheduled Jobs
645+
File: scheduled_jobs
644646
- Name: Revision History
645647
File: revhistory_dev_guide
646648
Distros: openshift-enterprise,openshift-dedicated
@@ -695,7 +697,7 @@ Topics:
695697
- Name: Python
696698
File: python
697699
- Name: Ruby
698-
File: ruby
700+
File: ruby
699701
- Name: Database Images
700702
Dir: db_images
701703
Topics:

Diff for: dev_guide/jobs.adoc

+8-17
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ xref:../architecture/core_concepts/deployments.adoc#replication-controllers[a
1919
replication controller]), runs any number of pods to completion. A job tracks the
2020
overall progress of a task and updates its status with information about active,
2121
succeeded, and failed pods. Deleting a job will clean up any pods it created.
22-
Jobs are part of the extensions Kubernetes API, which can be managed with `oc` commands like other
22+
Jobs are part of the Kubernetes API, which can be managed with `oc` commands like other
2323
xref:../cli_reference/basic_cli_operations.adoc#object-types[object types].
2424

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

2828
[[creating-a-job]]
29-
3029
== Creating a Job
3130

3231
A job configuration consists of the following key parts:
@@ -41,21 +40,16 @@ The following is an example of a `*job*` resource:
4140
====
4241
[source,yaml]
4342
----
44-
apiVersion: extensions/v1beta1
43+
apiVersion: batch/v1
4544
kind: Job
4645
metadata:
4746
name: pi
4847
spec:
49-
selector: <1>
50-
matchLabels:
51-
app: pi
52-
parallelism: 1 <2>
53-
completions: 1 <3>
54-
template: <4>
48+
parallelism: 1 <1>
49+
completions: 1 <2>
50+
template: <3>
5551
metadata:
5652
name: pi
57-
labels:
58-
app: pi
5953
spec:
6054
containers:
6155
- name: pi
@@ -64,15 +58,12 @@ spec:
6458
restartPolicy: Never
6559
----
6660
67-
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].
68-
2. Optional value for how many pods a job should run in parallel, defaults to `*completions*`.
69-
3. Optional value for how many successful pod completions is needed to mark a job completed, defaults to one.
70-
4. Template for the pod the controller creates.
61+
1. Optional value for how many pods a job should run in parallel, defaults to `*completions*`.
62+
2. Optional value for how many successful pod completions is needed to mark a job completed, defaults to one.
63+
3. Template for the pod the controller creates.
7164
====
7265

73-
7466
[[scaling-a-job]]
75-
7667
== Scaling a Job
7768

7869
A job can be scaled up or down by using the `oc scale` command with `--replicas`

Diff for: dev_guide/scheduled_jobs.adoc

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[[dev-guide-scheduled-jobs]]
2+
= Scheduled Jobs
3+
{product-author}
4+
{product-version}
5+
:data-uri:
6+
:icons:
7+
:experimental:
8+
:toc: macro
9+
:toc-title:
10+
:prewrap!:
11+
12+
toc::[]
13+
14+
== Overview
15+
16+
A _scheduled job_ builds on a regular
17+
xref:../dev_guide/jobs.adoc#dev-guide-jobs[job] by allowing you to specifically
18+
schedule how the job should be run. Scheduled jobs are part of the
19+
link:http://kubernetes.io/docs/user-guide/scheduled-jobs[Kubernetes] API, which
20+
can be managed with `oc` commands like other
21+
xref:../cli_reference/basic_cli_operations.adoc#object-types[object types].
22+
23+
ifdef::openshift-enterprise[]
24+
[NOTE]
25+
====
26+
As of {product-title} 3.3.1, Scheduled Jobs is a feature in Technology Preview.
27+
====
28+
endif::[]
29+
30+
[[creating-a-scheduledjob]]
31+
== Creating a Scheduled Job
32+
33+
A scheduled job configuration consists of the following key parts:
34+
35+
* A schedule specified in link:https://en.wikipedia.org/wiki/Cron[cron format].
36+
* A job template used when creating the next job.
37+
* An optional deadline (in seconds) for starting the job if it misses its
38+
scheduled time for any reason. Missed jobs executions will be counted as failed
39+
ones. If not specified, there is no deadline.
40+
* `*ConcurrencyPolicy*`: An optional concurrency policy, specifying how to treat
41+
concurrent jobs within a scheduled job. Only one of the following concurrent
42+
policies may be specified. If not specified, this defaults to allowing
43+
concurrent executions.
44+
** `Allow` allows Scheduled Jobs to run concurrently.
45+
** `Forbid` forbids concurrent runs, skipping the next run if the previous has not
46+
finished yet.
47+
** `Replace` cancels the currently running job and replaces
48+
it with a new one.
49+
* An optional flag allowing the suspension of a scheduled job. If set to `true`,
50+
all subsequent executions will be suspended.
51+
52+
The following is an example of a `*ScheduledJob*` resource:
53+
54+
====
55+
[source,yaml]
56+
----
57+
apiVersion: batch/v2alpha1
58+
kind: ScheduledJob
59+
metadata:
60+
name: pi
61+
spec:
62+
schedule: */1 * * * ? <1>
63+
jobTemplate: <2>
64+
spec:
65+
template:
66+
spec:
67+
containers:
68+
- name: pi
69+
image: perl
70+
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
71+
restartPolicy: Never
72+
----
73+
74+
1. Schedule for the job. In this example, a job will run every minute.
75+
2. Job template. This is similar to the xref:../dev_guide/jobs.adoc#creating-a-job[job example].
76+
====
77+
78+
ifdef::openshift-enterprise[]
79+
[[scheduledjob-known-issues]]
80+
== Known Issues
81+
82+
[[scheduledjob-known-issues-unable-to-edit]]
83+
=== Unable to Edit a Scheduled Job
84+
85+
There is a link:https://bugzilla.redhat.com/show_bug.cgi?id=1378368[known issue]
86+
when invoking `oc edit scheduledjob` due to an error that was already fixed in
87+
the latest version. However, due to significant code changes, this was not
88+
backported.
89+
90+
One possible solution is to use `oc patch` command instead of `oc edit`.
91+
92+
[[scheduledjob-known-issues-change-concurrency]]
93+
=== Unable to Change Concurrency Policy
94+
95+
There is a link:https://bugzilla.redhat.com/show_bug.cgi?id=1386463[known issue]
96+
when changing concurrency policy where no new jobs are created after that
97+
operation is run. The issue is still under investigation in the latest version.
98+
endif::[]

0 commit comments

Comments
 (0)