简体   繁体   English

如何在Tectonic kubernetes设置中禁用Ingress拦截错误

[英]How to disable interception of errors by Ingress in a Tectonic kubernetes setup

I have a couple of NodeJS backends running as pods in a Kubernetes setup, with Ingress-managed nginx over it. 我有一些NodeJS后端在Kubernetes设置中作为pod运行,Ingress管理的nginx在它上面。

These backends are API servers, and can return 400, 404, or 500 responses during normal operations. 这些后端是API服务器,在正常操作期间可以返回400,404或500个响应。 These responses would provide meaningful data to the client; 这些回复将为客户提供有意义的数据; besides the status code, the response has a JSON-serialized structure in the body informing about the error cause or suggesting a solution. 除了状态代码之外,响应在正文中具有JSON序列化结构,通知错误原因或建议解决方案。

However, Ingress will intercept these error responses, and return an error page. 但是,Ingress将拦截这些错误响应,并返回错误页面。 Thus the client does not receive the information that the service has tried to provide. 因此,客户端不会收到服务尝试提供的信息。

There's a closed ticket in the kubernetes-contrib repository suggesting that it is now possible to turn off error interception: https://github.com/kubernetes/contrib/issues/897 . 在kubernetes-contrib存储库中有一个已关闭的票据,表明现在可以关闭错误拦截: https//github.com/kubernetes/contrib/issues/897 Being new to kubernetes/ingress, I cannot figure out how to apply this configuration in my situation. 作为kubernetes / ingress的新手,我无法弄清楚如何在我的情况下应用此配置。

For reference, this is the output of kubectl get ingress <ingress-name> : (redacted names and IPs) 作为参考,这是kubectl get ingress <ingress-name>的输出:(编辑名称和IP)

Name:             ingress-name-redacted
Namespace:        default
Address:          127.0.0.1
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host                                Path  Backends
  ----                                ----  --------
  public.service.example.com
                                      /   service-name:80 (<none>)
Annotations:
  rewrite-target:         /
  service-upstream:       true
  use-port-in-redirects:  true
Events:                   <none>

I have solved this on Tectonic 1.7.9-tectonic.4. 我在Tectonic 1.7.9-tectonic上解决了这个问题。

In the Tectonic web UI, go to Workloads -> Config Maps and filter by namespace tectonic-system. 在Tectonic Web UI中,转到Workloads - > Config Maps并按命名空间tectonic-system过滤。

In the config maps shown, you should see one named "tectonic-custom-error". 在显示的配置映射中,您应该看到一个名为“tectonic-custom-error”的配置映射。

Open it and go to the YAML editor. 打开它然后转到YAML编辑器。

In the data field you should have an entry like this: 在数据字段中,您应该有一个这样的条目:

custom-http-errors: '404, 500, 502, 503' custom-http-errors:'404,500,502,503'

which configures which HTTP responses will be captured and be shown with the custom Tectonic error page. 它配置哪些HTTP响应将被捕获并显示在自定义Tectonic错误页面中。

If you don't want some of those, just remove them, or clear them all. 如果你不想要其中的一些,只需删除它们,或清除它们。

It should take effect as soon as you save the updated config map. 它应该在您保存更新的配置映射后立即生效。

Of course, you could to the same from the command line with kubectl edit : 当然,您可以使用kubectl编辑从命令行进行相同的操作

$> kubectl edit cm tectonic-custom-error --namespace=tectonic-system $> kubectl edit cm tectonic-custom-error --namespace = tectonic-system

Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM