Skip to Content
Kubernetes: Up and Running
book

Kubernetes: Up and Running

by Kelsey Hightower, Brendan Burns, Joe Beda
September 2017
Intermediate to advanced content levelIntermediate to advanced
269 pages
4h 38m
English
O'Reilly Media, Inc.
Content preview from Kubernetes: Up and Running

Chapter 10. Jobs

So far we have focused on long-running processes such as databases and web applications. These types of workloads run until either they are upgraded or the service is no longer needed. While long-running processes make up the large majority of workloads that run on a Kubernetes cluster, there is often a need to run short-lived, one-off tasks. The Job object is made for handling these types of tasks.

A Job creates Pods that run until successful termination (i.e., exit with 0). In contrast, a regular Pod will continually restart regardless of its exit code. Jobs are useful for things you only want to do once, such as database migrations or batch jobs. If run as a regular Pod, your database migration task would run in a loop, continually repopulating the database after every exit.

In this chapter we explore the most common Job patterns afforded by Kubernetes. We will also leverage these patterns in real-life scenarios.

The Job Object

The Job object is responsible for creating and managing pods defined in a template in the Job specification. These pods generally run until successful completion. The Job object coordinates running a number of pods in parallel.

If the Pod fails before a successful termination, the Job controller will create a new Pod based on the Pod template in the Job specification. Given that Pods have to be scheduled, there is a chance that your Job will not execute if the required resources are not found by the scheduler. Also, due to the nature ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kubernetes in Action

Kubernetes in Action

Marko Luksa
Kubernetes: Up and Running, 2nd Edition

Kubernetes: Up and Running, 2nd Edition

Brendan Burns, Joe Beda, Kelsey Hightower
Core Kubernetes

Core Kubernetes

Jay Vyas, Christopher Love
GitOps and Kubernetes

GitOps and Kubernetes

Todd Ekenstam, Billy Yuen, Jesse Suen, Alex Matyushentsev

Publisher Resources

ISBN: 9781491935668Errata PageSupplemental Content