Job
- 一次性执行任务,类似Linux中的job
- 应用场景:如离线数据处理,视频解码等业务
部署Job例子
docker pull perl:slim
job-test.yml
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl:slim
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(6000)"]
restartPolicy: Never
backoffLimit: 4
backoffLimit:
.spec.backoffLimit
用于设置Job的容错次数,默认值为6。当Job运行的Pod失败次数到达.spec.backoffLimit
次时,Job Controller不再新建Pod,直接停止运行这个Job,将其运行结果标记为Failure。另外,Pod运行失败后再次运行的时间间隔呈递增状态,例如10s,20s,40s
运行job
运行job
kubectl apply -f job-test.yml
查看pod日志
kubectl logs -f pi-7nrtv
删除job
kubectl delete -f job-test.yml