如何为 gloo 入口控制器设置超时

How to set timeout for gloo ingress controller

我正在用 kubernetes 集群中的 gloo 入口控制器替换 nginx 入口,并想为 response.There 设置超时是 nginx 中对此的注释。

nginx.ingress.kubernetes.io/proxy-read-timeout: "60"

在 gloo-ingress-controller 中是否有类似的东西,或者我是否必须为此使用虚拟服务?

您应该与 Gloo 一起使用的唯一注释是 kubernetes.io/ingress.class: gloo,这是将 Ingress 对象标记为由特定 Ingress 控制器处理的标准方法。如果您将 Gloo 添加为集群的默认 Ingress 控制器,则此要求将消失。另外,根据 documentation:

If you need more advanced routing capabilities, we encourage you to use Gloo VirtualServices by installing as glooctl install gateway.

Gloo Gateway uses Kubernetes Custom Resources instead of Ingress Objects as the only way to configure Ingress’ beyond their basic routing spec is to use lots of vendor-specific Kubernetes Annotations to your Kubernetes manifests.

所以您应该使用 VirtualService 来实现您的目标。你可以看下面的例子:

apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
  name: 'default'
  namespace: 'gloo-system'
spec:
  virtualHost:
    domains:
    - '*'
    routes:
    - matchers:
       - prefix: '/petstore'
      routeAction:
        single:
          upstream:
            name: 'default-petstore-8080'
            namespace: 'gloo-system'
      options:
        timeout: '20s'
        retries:
          retryOn: 'connect-failure'
          numRetries: 3
          perTryTimeout: '5s'

希望对您有所帮助。