Using Jobs
The purpose of the Job resource in Kubernetes is to run tasks that can complete, which makes them not ideal for long-running applications, but great for batch jobs or similar tasks that can benefit from parallelism.
Here's what a Job spec YAML looks like:
job-1.yaml
apiVersion: batch/v1 kind: Job metadata: name: runner spec: template: spec: containers: - name: run-job image: node:lts-jessie command: ["node", "job.js"] restartPolicy: Never backoffLimit: 4
This Job will start a single Pod, and run a command, node job.js
, until it completes, at which point the Pod will shut down. In this and the future examples, we assume that the container image used has a file, job.js
, that runs...