带有睡眠命令的Kubernetes Pod需要时间才能删除
目前,在Kubectl delete命令之后,可以终止POD需要很长时间。我感觉可能是因为睡眠命令。
如何使容器停止更快? 我应该在这里使用哪些最佳实践?
apiVersion: apps/v1
kind: Deployment
...
spec:
template:
spec:
containers:
- image: alpine
..
command:
- /bin/sh
- -c
- |
trap : TERM INT
while true; do
# some code to check something
sleep 10
done
我的方法是“陷阱:术语int”正确的方法吗?目前,我看不到任何积极的效果...
当我终止豆荚时,命令需要几秒钟才能返回。
kubectl delete pod my-pod
Currently it takes quite a long time before the pod can be terminated after a kubectl delete command. I have the feeling that it could be because of the sleep command.
How can I make the container stop faster?
What best practices should I use here?
apiVersion: apps/v1
kind: Deployment
...
spec:
template:
spec:
containers:
- image: alpine
..
command:
- /bin/sh
- -c
- |
trap : TERM INT
while true; do
# some code to check something
sleep 10
done
Is my approach with "trap: TERM INT" correct? At the moment I don't see any positive effect...
When I terminate the pod it takes several seconds for the command to come back.
kubectl delete pod my-pod
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
terminationgraceperiodseconds
添加到您的规格中:Add
terminationGracePeriodSeconds
to your spec will do: