我在kubernetes集群上部署了django,在readinessProbe中,我运行python、manage.py、migrate、--check。我可以看到,此命令的返回值为0,但pod从未准备好。
我的部署代码片段:
containers:
- name: myapp
...
imagePullPolicy: Always
readinessProbe:
exec:
command: ["python", "manage.py", "migrate", "--check"]
initialDelaySeconds: 15
periodSeconds: 5 当我描述还没有准备好的吊舱时:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 66s default-scheduler Successfully assigned ... Normal Pulled 66s kubelet Successfully pulled image ...
Normal Created 66s kubelet Created container ...
Normal Started 66s kubelet Started container ...
Warning Unhealthy 5s (x10 over 50s) kubelet Readiness probe failed:我可以看到,migrate --check通过在容器中execing返回0,容器仍然处于未就绪状态,并且正在运行。
python manage.py migrate
echo $?
0作为readinessProbe传递的exec命令有什么问题吗?
我使用的kubernetes服务器的版本是1.21.7。我的部署的基本映像是python:3.7-瘦。
发布于 2022-01-21 08:12:22
解决这个问题的办法是增加timeoutSeconds parameter, which is by default set to 1 second
探测超时后的
timeoutSeconds:秒数。默认为1秒。最小值为1.在增加timeoutSeconds参数后,应用程序能够传递就绪探测。
将timeoutSeconds参数设置为5的部署示例片段:
containers:
- name: myapp
...
imagePullPolicy: Always
readinessProbe:
exec:
command: ["python", "manage.py", "migrate", "--check"]
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 5https://stackoverflow.com/questions/70720189
复制相似问题