gpt4 book ai didi

docker - 设置Pod重新启动限制

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

我们可以像kubernetes中的Docker swarm一样设置Pod Restart Limit 吗?

Docker swarm restart_policy:


    condition: any
delay: 60s
max_attempts: 2
window: 60s

或其他任何方式,因为k8s种部署不支持重启策略 neveronfailure
我的Deployment.yaml:-
apiVersion: apps/v1
kind: Deployment
metadata:
name: xyz
labels:
app: xyz
spec:
replicas: 1
selector:
matchLabels:
app: xyz
template:
metadata:
labels:
app: xyz
spec:
containers:
- name: xyz
image: x.y.z
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: x
restartPolicy: Never

错误 is invalid: spec.template.spec.restartPolicy: Unsupported value: "Never": supported values: "Always"

最佳答案

运行kubectl run --help | grep restart
您将看到有一个重新启动策略设置,如下所示

 --restart='Always': The restart policy for this Pod.  
Legal values [Always, OnFailure, Never].
If set to 'Always' a deployment is created, if set to 'OnFailure' a job is created,
if set to 'Never', a regular pod is created.
For the latter two --replicas must be 1. Default 'Always', for CronJobs `Never`.
maxRetries还有一个新选项
$ cat pod_retry.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
restartPolicy: "OnFailure"
maxRetries: "3" // Max retries is 3
containers:
- image: nginx:1.7.9
name: test-pod
command:
- /bin/ls
- hello

关于docker - 设置Pod重新启动限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59301413/

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