This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 31. Jobs
31.1. Overview 링크 복사링크가 클립보드에 복사되었습니다!
A job, in contrast to a replication controller, runs a pod with any number of replicas 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 pod replicas it created. Jobs are part of the Kubernetes API, which can be managed with oc
commands like other object types.
See the Kubernetes documentation for more information about jobs.
31.2. Creating a Job 링크 복사링크가 클립보드에 복사되었습니다!
A job configuration consists of the following key parts:
- A pod template, which describes the application the pod will create.
-
An optional
parallelism
parameter, which specifies how many pod replicas running in parallel should execute a job. If not specified, this defaults to the value in thecompletions
parameter. -
An optional
completions
parameter, specifying how many concurrently running pods should execute a job. If not specified, this value defaults to one.
The following is an example of a job
resource:
- Label selector of the pod to run. It uses the generalized label selectors.
-
Optional value for how many pod replicas a job should run in parallel; defaults to
completions
. - Optional value for how many successful pod completions are needed to mark a job completed; defaults to one.
- Template for the pod the controller creates.
31.3. Scaling a Job 링크 복사링크가 클립보드에 복사되었습니다!
A job can be scaled up or down by using the oc scale
command with the --replicas
option, which, in the case of jobs, modifies the spec.parallelism
parameter. This will result in modifying the number of pod replicas running in parallel, executing a job.
The following command uses the example job above, and sets the parallelism
parameter to three:
oc scale job pi --replicas=3
$ oc scale job pi --replicas=3
Scaling replication controllers also uses the oc scale
command with the --replicas
option, but instead changes the replicas
parameter of a replication controller configuration.
31.4. Setting Maximum Duration 링크 복사링크가 클립보드에 복사되었습니다!
When defining a Job
, you can define its maximum duration by setting the activeDeadlineSeconds
field. It is specified in seconds and is not set by default. When not set, there is no maximum duration enforced.
The maximum duration is counted from the time when a first pod gets scheduled in the system, and defines how long a job can be active. It tracks overall time of an execution and is irrelevant to the number of completions (number of pod replicas needed to execute a task). After reaching the specified timeout, the job is terminated by OpenShift Enterprise.
The following example shows the part of a Job
specifying activeDeadlineSeconds
field for 30 minutes:
spec: activeDeadlineSeconds: 1800
spec:
activeDeadlineSeconds: 1800