zoukankan      html  css  js  c++  java
  • 【k8s】job-backoffLimit

    环境

    1. kubernetes 1.20.4
    2. Spring Boot 2.5.0-M3

    目标

    backoffLimit 表示回退限制,可以指定重试几次后将 Job 标记为失败。

    示例

    Job.yaml

    apiVersion: batch/v1
    kind: Job
    metadata:
      name: busybox
    spec:
      backoffLimit: 2
      template:
        spec:
          containers:
            - name: busybox
              image: busybox:1.30.0
              command: ["/bin/sh", "-c", "sleep 10;date;exit 1"]
          restartPolicy: Never
    

    查看

    [root@master ~]# kubectl get job,pod
    NAME                COMPLETIONS   DURATION   AGE
    job.batch/busybox   0/1           4m34s      4m34s
    
    NAME                READY   STATUS   RESTARTS   AGE
    pod/busybox-dhrkt   0/1     Error    0          4m34s
    pod/busybox-kcx46   0/1     Error    0          4m
    pod/busybox-tlk48   0/1     Error    0          4m21s
    

    可以看到重试了两次,但是还是失败了,后面就没有再次重试了。

    查看详细信息

    [root@master ~]# kubectl describe job busybox
    Name:           busybox
    Namespace:      default
    Selector:       controller-uid=461bdd7d-4510-4c55-ac45-211b5621219f
    Labels:         controller-uid=461bdd7d-4510-4c55-ac45-211b5621219f
                    job-name=busybox
    Annotations:    <none>
    Parallelism:    1
    Completions:    1
    Start Time:     Tue, 06 Apr 2021 22:09:53 +0800
    Pods Statuses:  0 Running / 0 Succeeded / 3 Failed
    Pod Template:
      Labels:  controller-uid=461bdd7d-4510-4c55-ac45-211b5621219f
               job-name=busybox
      Containers:
       busybox:
        Image:      busybox:1.30.0
        Port:       <none>
        Host Port:  <none>
        Command:
          /bin/sh
          -c
          sleep 10;date;exit 1
        Environment:  <none>
        Mounts:       <none>
      Volumes:        <none>
    Events:
      Type     Reason                Age    From            Message
      ----     ------                ----   ----            -------
      Normal   SuccessfulCreate      5m26s  job-controller  Created pod: busybox-dhrkt
      Normal   SuccessfulCreate      5m13s  job-controller  Created pod: busybox-tlk48
      Normal   SuccessfulCreate      4m52s  job-controller  Created pod: busybox-kcx46
      Warning  BackoffLimitExceeded  4m32s  job-controller  Job has reached the specified backoff limit
    

    总结

    backoffLimit 表示回退限制,可以指定重试几次后将 Job 标记为失败。

    附录

  • 相关阅读:
    我的2020书单
    记录一次克隆硬盘的经历
    npm简单介绍
    批量处理Excel从格式xls到xlsx
    SQL经典实例笔记
    在字符串中找出连续最长的数字串
    将数字转化成字符串
    寄存器位读写,结构体位域定义,位域操作,位操作
    android C/C++ source files 全局宏定义 .
    android2.3 -添加自定义按键:作唤醒功能 .
  • 原文地址:https://www.cnblogs.com/jiangbo44/p/14624598.html
Copyright © 2011-2022 走看看