apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-http
spec:
restartPolicy: Never
containers:
- args:
- /server
image: k8s.gcr.io/liveness
livenessProbe:
httpGet:
# when "host" is not defined, "PodIP" will be used
# host: my-host
# when "scheme" is not defined, "HTTP" scheme will be used. Only "HTTP" and "HTTPS" are allowed
# scheme: HTTPS
path: /healthz
port: 8080
httpHeaders:
- name: X-Custom-Header
value: Awesome
initialDelaySeconds: 15
timeoutSeconds: 1
name: liveness
2条答案
按热度按时间wqsoz72f1#
有一种方法,你必须在pod配置中添加
livenessProbe
配置和restartPolicy
never
。1.当容器死亡时,因为
restartPolicy
永远不会,pod状态变为Failed
。比如说;
字符串
这是参考资料;https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
fhity93d2#
如果在其中一个容器发生故障时立即终止pod并不重要,则可以考虑为整个pod设置全局超时。这可以通过设置
activeDeadlineSeconds
来实现,如这里为v.1.17指定的:https://v1-17.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#pod-v1-core