如何安排Pod重新启动 [英] How to schedule pods restart
本文介绍了如何安排Pod重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以根据时间自动重启Pod?
Is it possible to restart pods automatically based on the time?
例如,我想每天早上8:00 AM重新启动集群的容器.
For example, I would like to restart the pods of my cluster every morning at 8.00 AM.
推荐答案
有一个特定的资源:这里有个例子:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: your-cron
spec:
schedule: "*/20 8-19 * * 1-5"
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
metadata:
labels:
app: your-periodic-batch-job
spec:
containers:
- name: my-image
image: your-image
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
如果要在启动新Pod时替换旧Pod,请
将spec.concurrencyPolicy
更改为Replace
.使用Forbid
,如果旧的Pod仍在运行,则将跳过新的Pod创建.
change spec.concurrencyPolicy
to Replace
if you want to replace the old pod when starting a new pod. Using Forbid
, the new pod creation will be skip if the old pod is still running.
这篇关于如何安排Pod重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文