gpt4 book ai didi

Kubernetes, active 探测失败,但 Pod 处于运行状态

转载 作者:行者123 更新时间:2023-12-04 21:03:06 26 4
gpt4 key购买 nike

我正在尝试使用 kubernetes 进行蓝绿色部署,我已遵循它,https://www.ianlewis.org/en/bluegreen-deployments-kubernetes , 那没问题。
我添加了一个活性探针来执行健康检查,

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: flask-1.3
spec:
replicas: 2
template:
metadata:
labels:
name: app
version: "1.3"
spec:
containers:
- name: appflask
image: 192.168.99.100:5000/fapp:1.2
livenessProbe:
httpGet:
path: /index2
port: 5000
failureThreshold: 1
periodSeconds: 1
initialDelaySeconds: 1
ports:
- name: http
containerPort: 5000

路径“index2”不存在,我想测试一个失败的部署。问题是当我执行:
 kubectl get pods -o wide

几秒钟内,其中一个 pod 处于“正在运行”状态
NAME                         READY   STATUS             RESTARTS   AGE     IP             NODE    NOMINATED NODE   READINESS GATES

flask-1.3-6c644b8648-878qz 0/1 CrashLoopBackOff 6 6m19s 10.244.1.250 node <none> <none>
flask-1.3-6c644b8648-t6qhv 0/1 CrashLoopBackOff 7 6m19s 10.244.2.230 nod2e <none> <none>

几秒钟后,当 live 总是失败时,一个 pod 正在运行:
NAME                         READY   STATUS             RESTARTS   AGE 

IP NODE NOMINATED NODE READINESS GATES

flask-1.3-6c644b8648-878qz 1/1 Running 7 6m20s 10.244.1.250 node <none> <none>
flask-1.3-6c644b8648-t6qhv 0/1 CrashLoopBackOff 7 6m20s 10.244.2.230 nod2e <none> <none>

在将它运行回 CrashLoopBackOff 之后,问题是,如果 livenesprobe 总是失败,为什么它会在几秒钟内保持运行?

提前致谢

最佳答案

你应该看看 Readiness probe相反,或两者兼而有之。

Readiness and liveness probes can be used in parallel for the same container. Using both can ensure that traffic does not reach a container that is not ready for it, and that containers are restarted when they fail.



Liveness probe检查您的应用程序是否在您的 中处于健康状态已经在运行 pod .

Readiness probe实际上会检查您的 pod 是否准备好接收流量。因此,如果没有 /index2 端点,它永远不会显示为 运行

关于Kubernetes, active 探测失败,但 Pod 处于运行状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54039652/

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