k8s cronjob

k8s cronjob 任务模版

  • k8s cronjob 任务模版
cat > ${k8s_resource_list}-cronjob.yaml << EOF
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: ${k8s_resource_list}
  namespace: ${namespace}
spec:
  schedule: "*/1 * * * *"  
  startingDeadlineSeconds: 300 
  concurrencyPolicy: Forbid  
  suspend: false  
  jobTemplate:
    spec:
      parallelism: 2 #同时执行的pod 数量,即副本数量
      backoffLimit: 4 # 最大允许失败的次数
      template:
        spec:
          restartPolicy: OnFailure
          volumes:
            - name: storage
              hostPath:
                path: /applogs/project/volume-${namespace}/${k8s_resource_list}
                type: ""
            - name: volume-localtime
              hostPath:
                path: /etc/localtime
          containers:
            - name: ${k8s_resource_list}
              image: ${mirror_store}/${image_name}:${BUILD_TIMESTAMP}
              volumeMounts:
                - name: volume-localtime
                  mountPath: /etc/localtime
                - name: storage
                  mountPath: /export/home/webroot/${namespace}/extend/logs 
EOF


posted @ 2023-11-08 11:43  lixinliang  阅读(15)  评论(0编辑  收藏  举报