Optional parameters
backoffLimit: Number of retries for pods launched by the job. If you want your pods to never restart, you need to set it at 0. However due to some issuewhere pod can’t be restarted beyond backoffLimit it’s better, if you use “restartPolicy : Never”.
Here is a more detailed cronjob example with most of the parameters:
apiVersion: batch/v1beta1 kind: CronJob metadata: name: test spec: schedule: "30 16,17,18,19 * * *" concurrencyPolicy: "Forbid" failedJobsHistoryLimit: 10 startingDeadlineSeconds: 600 # 10 min jobTemplate: spec: backoffLimit: 0 activeDeadlineSeconds: 3300 # 55min template: spec: containers: - name: hello image: python:3.6-slim command: ["python"] args: ["/usr/src/app/job_offers.py"] restartPolicy: Never
实例配置:
kubectl get cronjob job-2528049150-app-v1-0 -n data-infra -o yaml ********** spec: concurrencyPolicy: Allow failedJobsHistoryLimit: 10 jobTemplate: metadata: annotations: helm.sh/namespace: data-infra helm.sh/path: app helm.sh/release: job-2528049150 creationTimestamp: null labels: controller.caicloud.io/chart: app controller.caicloud.io/release: job-2528049150 spec: activeDeadlineSeconds: 36000 backoffLimit: 0 completions: 1 parallelism: 1 template: metadata: annotations: helm.sh/namespace: data-infra helm.sh/path: app helm.sh/release: job-2528049150 creationTimestamp: null labels: controller.caicloud.io/chart: app controller.caicloud.io/name: job-2528049150-app-v1-0 controller.caicloud.io/release: job-2528049150 spec: containers: - command: - python - -m - fashion_bi.FbMainServer env: - name: POD_NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace - name: POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - name: POD_IP valueFrom: fieldRef: apiVersion: v1 fieldPath: status.podIP - name: NODE_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: spec.nodeName - name: SERVING_TYPE value: ins image: cargo.caicloudprivatetest.com/data-infra_pro/fb_main_server:3.7 imagePullPolicy: Always name: c0 resources: limits: cpu: "2" memory: 4Gi requests: cpu: 250m memory: 512Mi securityContext: privileged: false terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Never schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 schedule: 00 21 * * * successfulJobsHistoryLimit: 10 suspend: false status: lastScheduleTime: 2019-04-25T21:00:00Z
所有评论(0)