[英]How to detect when a Kubernetes liveness / readiness probe fails and invoke an endpoint passing some information about the pod
[英]Is it possible to specify a delay for pod restart when Kubernetes liveness probe fails?
得到了一個簡單的 REST API 服務器,使用 python gunicorn 構建,它運行多個線程來接受請求。 運行一段時間后,其中一些線程崩潰。 有一個腳本來檢測死線程的數量(使用日志文件)。 一旦這個數字超過某個閾值,我們就想重新啟動 gunicorn。 此腳本配置為用作liveness probe 。
該腳本工作正常並按預期重新啟動 pod。 但是有一些活動線程仍在處理請求。 此外,gunicorn 保留了一個它無法處理的已接受請求的積壓隊列,因為其他請求正在處理中。 有沒有辦法指定 pod 重啟的延遲,以便其他正在運行的線程和積壓請求有一些時間來完成處理?
您可以使用 terminateGracePeriodSeconds 配置優雅的 pod terminationGracePeriodSeconds
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test
spec:
replicas: 1
template:
spec:
containers:
- name: test
image: ...
terminationGracePeriodSeconds: 60
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.