gpt4 book ai didi

kubernetes - 无法访问docker时如何限制ImagePullBackOff的重试次数?

转载 作者:行者123 更新时间:2023-12-02 12:12:38 26 4
gpt4 key购买 nike

在我的 kubernetes 作业中,我写错了 docker name,我发现我的作业一直处于 ImagePullBackOff 状态。我要的是job release 资源,docker image 名字错了就停止拉取。我注意到有一个 imagePullPolicy 配置,但似乎不符合我的要求。我希望该作业始终拉取 docker 图像,但对拉取有重试次数限制。 kubernetes 支持这个 Action 吗?

最佳答案

您应该使用 backoffLimitactiveDeadlineSeconds 作为通用 Controller ,在指定次数的失败后退出作业。

例子

 apiVersion: batch/v1
kind: Job
metadata:
name: myjob
namespace: default
spec:
backoffLimit: 5
activeDeadlineSeconds: 100
template:
metadata:
name: myjob
spec:
containers:
- name: nginx
image: wrong_image_name
restartPolicy: OnFailure

By setting the activeDeadlineSeconds field of the Job to a number of seconds. The activeDeadlineSeconds applies to the duration of the job, no matter how many Pods are created.

Once a Job reaches activeDeadlineSeconds, all of its running Pods are terminated and the Job status will become type: Failed with reason: DeadlineExceeded

关于kubernetes - 无法访问docker时如何限制ImagePullBackOff的重试次数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61054703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com