赞
踩
一:批处理任务模式
二:k8s 并行批处理3种Job
- apiVersion: batch/v1
- kind: Job
- metadata:
- name: pai
- labels:
- jobgroup: jobexample
- spec:
- parallelism: 2 #并行几个任务
- completions: 4 #期望几个任务可以完成
- template:
- metadata:
- name: jobexample
- labels:
- jobgroup: jobexample
- spec:
- containers:
- - name: pai
- image: perl
- imagePullPolicy: IfNotPresent
- command: ["perl", "-Mbignum=bi", "-wle", "print bpi(2000)"]
- restartPolicy: OnFailure #Never 没有always用法
- #最多尝试几次任务
- backoffLimit: 4
- #任务最多运行多长时间
- activeDeadlineSeconds: 100
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
- apiVersion: batch/v1beta1
- kind: CronJob
- metadata:
- name: hello
- spec:
- #Forbid 当前job没有运行完成,不会创建新的job
- #Allow 运行多个job同时运行,不建议使用这个策略
- #Replace 这个job会替换前一个没有运行完成的job,重新产生一个新job
- concurrencyPolicy: Replace
- suspend: true #暂停job任务执行
- schedule: "*/1 * * * *"
- successfulJobsHistoryLimit: 3
- failedJobsHistoryLimit: 2
- jobTemplate:
- spec:
- template:
- spec:
- containers:
- - name: hello
- image: busybox
- imagePullPolicy: IfNotPresent
- args:
- - /bin/sh
- - -c
- - date; echo Hello from the Kubernetes cluster
- restartPolicy: OnFailure
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。