gpt4 book ai didi

kubernetes - 从部署配置配置 Pod 的重启策略

转载 作者:行者123 更新时间:2023-12-04 13:12:47 25 4
gpt4 key购买 nike

我们正在使用 Openshift(Kubernetes 的托管版本),我正在努力为我们的部署配置创建的所有 pod 将 pod 重启策略从“始终”设置为“从不”,但我不确定在哪里在 yaml 中进行此更改。

我们的部署配置类似于:

kind: DeploymentConfig
metadata:
generation: 19
name: my-deployment-config
namespace: my-deployment-config-namespace
selfLink: >-
...
uid: af918183-c780-11ea-8945-525400d3e4d9
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
name: my-selector
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
...
spec:
containers:
- image: >-
(image source)
imagePullPolicy: Always
name: my-container
ports:
- containerPort: 8080
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30

当我尝试将那里的 restartPolicy 从“始终”更改为“从不”时,我遇到了

Failed to process the resource. Reason:DeploymentConfig.apps.openshift.io"my-deployment-config" is invalid:spec.template.spec.restartPolicy: Unsupported value: "Never":supported values: "Always"

The Kubernetes documentation以及 Openshift documentation on restart 策略显示 pod 可以配置为 Always、Never 或 OnFailure。

那么我该如何从部署配置中做到这一点呢?

最佳答案

对于 restartPolicy,部署只允许 Always。请参阅此文档 https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#pod-template

另请参阅很久以前的问题报告。 https://github.com/kubernetes/kubernetes/issues/24725

仅允许等于 Always 的 .spec.template.spec.restartPolicy,如果未指定,则为默认值。

注意:DaemonSets、ReplicaSets、ReplicationController 也是如此。

关于kubernetes - 从部署配置配置 Pod 的重启策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63400156/

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