zoukankan      html  css  js  c++  java
  • k8s cronjob设置作业失败后退出不重复执行

    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
    

      

  • 相关阅读:
    xib上的控件属性为什么要使用weak
    authenticating with the app store 一直卡住--问题记录
    ios-tableview加载卡顿的解决方案
    魔链的参考文档--移动应用之deeplink唤醒app
    iOS中Category和Extension 原理详解
    剑指offer 9-10:青蛙跳台阶与Fibonacii数列
    剑指offer 8:旋转数组的最小数字
    设计模式:单例模式(singleton)
    设计模式:工厂模式
    C++智能指针解析
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/10773375.html
Copyright © 2011-2022 走看看