滚动更新 Kubernetes 时 Postgres 连接被拒绝(通过 CloudSQL 代理)
Postgres connection refused (via CloudSQL proxy) when doing rolling update Kubernetes
当我进行滚动更新时,我收到 Sentry 的异常消息:
DatabaseError('server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request.',...)
我在每个 Pod 中有两个容器 运行,我的 app
容器和一个 cloudsql-proxy
容器,app
容器用来与云通信 SQL.
有没有办法确保我的应用程序容器在 30 秒的宽限期 (terminationGracePeriodSeconds) 内首先关闭?
换句话说,我想耗尽连接并在 cloudsql-proxy
被取出之前完成所有当前请求。
如果我能指定在 30 秒的宽限期内先关闭 app
容器,然后再关闭 cloudsql-proxy
.
容器,那将是理想的选择
清单中的这个 suggests setting the “terminationGracePeriodSeconds” or the "PreStop hook"。
另一个可行的想法是 运行 不同 pods 中的两个容器允许对部署的 rolling update. You might also want to consider using Init Containers 进行精细控制,从而允许代理在您的应用程序之前准备就绪容器。
当我进行滚动更新时,我收到 Sentry 的异常消息:
DatabaseError('server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request.',...)
我在每个 Pod 中有两个容器 运行,我的 app
容器和一个 cloudsql-proxy
容器,app
容器用来与云通信 SQL.
有没有办法确保我的应用程序容器在 30 秒的宽限期 (terminationGracePeriodSeconds) 内首先关闭?
换句话说,我想耗尽连接并在 cloudsql-proxy
被取出之前完成所有当前请求。
如果我能指定在 30 秒的宽限期内先关闭 app
容器,然后再关闭 cloudsql-proxy
.
清单中的这个
另一个可行的想法是 运行 不同 pods 中的两个容器允许对部署的 rolling update. You might also want to consider using Init Containers 进行精细控制,从而允许代理在您的应用程序之前准备就绪容器。