etl*_*lsh 7 python uwsgi kubernetes
我正在运行 uwsgi+flask 应用程序,该应用程序作为 k8s pod 运行。
当我部署一个新的 pod(一个新版本)时,现有的 pod 会收到 SIGTERM。
这将导致主停止接受新的连接在同一时刻,是什么原因导致问题的LB仍请求传递给吊舱(几秒钟)。
我希望主人在停止接受新连接之前等待 30 秒(当获得 SIGTERM 时)但找不到方法,这可能吗?
我的 uwsgi.ini 文件:[uwsgi]
;https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html
http = :8080
wsgi-file = main.py
callable = wsgi_application
processes = 2
enable-threads = true
master = true
reload-mercy = 30
worker-reload-mercy = 30
log-5xx = true
log-4xx = true
disable-logging = true
stats = 127.0.0.1:1717
stats-http = true
single-interpreter= true
;https://github.com/containous/traefik/issues/615
http-keepalive=true
add-header = Connection: Keep-Alive
Run Code Online (Sandbox Code Playgroud)
使用 uwsgi 似乎无法实现:
https://github.com/unbit/uwsgi/issues/1974
解决方案 - (如在此 kubernetes 问题中所述):
https://github.com/kubernetes/contrib/issues/1140
是使用 prestop 钩子,相当丑陋但有助于实现零停机时间:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx
spec:
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
lifecycle:
preStop:
exec:
command: ["/bin/sleep","5"]
Run Code Online (Sandbox Code Playgroud)
模板取自这个答案:https : //stackoverflow.com/a/39493421/3659858
归档时间: |
|
查看次数: |
2292 次 |
最近记录: |