kubernetes - Kubernetes CronJob 创建的已完成 pod 在一段时间后被删除
问题描述
我使用下面的 yaml 文件创建了一个 CronJob。
kind: CronJob
metadata:
name: $DEPLOY_NAME
spec:
# Run the job once a day at 8 PM
schedule: "0 20 * * *"
# If the previous job is not yet complete during the scheduled time, do not start the next job
concurrencyPolicy: Forbid
jobTemplate:
spec:
# The pods will be available for 3 days (259200 seconds) so that logs can be checked in case of any failures
ttlSecondsAfterFinished: 259200
template:
spec:
containers:
- name: $DEPLOY_NAME
image: giantswarm/tiny-tools
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "0.01"
memory: 256Mi
limits:
cpu: "0.5"
memory: 512Mi
command: ["/bin/sh"]
args: ["-c", "cd /home/tapi && sh entrypoint.sh"]
如 中所述ttlSecondsAfterFinished
,k8s 将我的工作保留在集群中。但是,作业创建的 pod(完成后)会在一段时间后被删除。
根据垃圾收集策略,我的 pod 对象应该取决于我的工作。而且由于作业对象没有被垃圾收集,我的 pod 对象也应该保持活动状态。我错过了什么吗?
解决方案
.spec.successfulJobsHistoryLimit 和 .spec.failedJobsHistoryLimit 字段是可选的。这些字段指定应保留多少已完成和失败的作业。默认情况下,它们分别设置为 3 和 1。
您可能需要将这些字段设置为适当的值
推荐阅读
- javascript - 掉落时跳跃的物品反应漂亮 dnd
- c++ - RTTR - 反映库中的现有方法
- google-cloud-platform - 使用 GoogleCloud Run 运行 Keycloak
- r - R:在银河坐标系中以 Mollweide 投影绘制天空图
- three.js - 在 three.js 中加载大型模型
- asp.net - 我想知道我们如何在 asp.net mvc 5 中对静态图像设置分页
- continuous-integration - Concourse CI 作业无法卷曲到主机上的服务获取无法连接到 xxx.xxx.xxx。端口 9090:没有到主机的路由
- automation - 自动提取文件名中带有密码的压缩文件
- google-app-engine - 如何在 App Engine 文档中查看文档?
- python - 如何指定删除 .txt 文件中的短语,其中一个短语包含“x”另一个“x”和“y”(其中要删除 x 但不删除 x 和 y)