如果后端健康检查失败,如何配置 Google Cloud Platform Ingress 以提供静态页面?

How do I configure the Google Cloud Platform Ingress to serve a static page if the backend health check fails?

我在 GCP Kubernetes 上有一个网站 运行。它最初使用 Ingress 接收流量,然后向下传递到 Deployment/Workload。

如果由于某种原因后端健康检查失败,我们会收到一个通用的 500 状态页面。我想为消费者提供该页面的更时尚版本。理想情况下,我们会调整系统,这样就不会发生这种情况,但有时它仍然会发生。

目前 GCLB 中还没有这样的功能可以做到这一点。您始终可以使用自己的入口控制器 like Nginx 并设置以下配置:

error_page 500 502 503 504 /custom_50x.html;
        location = /custom_50x.html {
                root /usr/share/nginx/html;
                internal;
        }