【问题标题】:Need help troubleshooting Istio IngressGateway HTTP ERROR 503需要帮助解决 Istio IngressGateway HTTP ERROR 503
【发布时间】:2020-11-19 01:22:16
【问题描述】:

我的测试环境集群有以下配置:

全局网格策略(作为集群设置的一部分由我们的组织安装):kubectl describe MeshPolicy default 的输出

Name:         default
Namespace:
Labels:       operator.istio.io/component=Pilot
              operator.istio.io/managed=Reconcile
              operator.istio.io/version=1.5.6
              release=istio
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"authentication.istio.io/v1alpha1","kind":"MeshPolicy","metadata":{"annotations":{},"labels":{"operator.istio.io/component":...
API Version:  authentication.istio.io/v1alpha1
Kind:         MeshPolicy
Metadata:
  Creation Timestamp:  2020-07-23T17:41:55Z
  Generation:          1
  Resource Version:    1088966
  Self Link:           /apis/authentication.istio.io/v1alpha1/meshpolicies/default
  UID:                 d3a416fa-8733-4d12-9d97-b0bb4383c479
Spec:
  Peers:
    Mtls:
Events:  <none>

我相信上述配置可以让服务以 mTls 模式接收连接。

DestinationRule : kubectl describe DestinationRule commerce-mesh-port -n istio-system 的输出

Name:         commerce-mesh-port
Namespace:    istio-system
Labels:       <none>
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"networking.istio.io/v1alpha3","kind":"DestinationRule","metadata":{"annotations":{},"name":"commerce-mesh-port","namespace"...
API Version:  networking.istio.io/v1beta1
Kind:         DestinationRule
Metadata:
  Creation Timestamp:  2020-07-23T17:41:59Z
  Generation:          1
  Resource Version:    33879
  Self Link:           /apis/networking.istio.io/v1beta1/namespaces/istio-system/destinationrules/commerce-mesh-port
  UID:                 4ef0d49a-88d9-4b40-bb62-7879c500240a
Spec:
  Host:  *
  Ports:
    Name:      commerce-mesh-port
    Number:    16443
    Protocol:  TLS
  Traffic Policy:
    Tls:
      Mode:  ISTIO_MUTUAL
Events:      <none>

Istio 入口网关:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: finrpt-gateway
  namespace: finrpt
spec:
  selector:
    istio: ingressgateway # use Istio's default ingress gateway
  servers:
  - port:
      name: https
      number: 443
      protocol: https
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
    hosts:
    - "*"
  - port:
      name: http
      number: 80
      protocol: http
    tls:
      httpsRedirect: true
    hosts:
    - "*"

我创建了一个用于 TLS 的密钥,并使用它来终止网关上的 TLS 流量(在 SIMPLE 模式下配置)

接下来,我在同一个命名空间中配置了我的 VirtualService 并为 HTTP 进行了 URL 匹配:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: finrpt-virtualservice
  namespace: finrpt
spec:
  hosts:
  - "*"
  gateways:
  - finrpt-gateway
  http:
  - match:
    - queryParams:
        target:
          exact: "commercialprocessor"
      ignoreUriCase: true
    route:
    - destination:
        host: finrpt-commercialprocessor
        port:
          number: 8118

Service CommercialProcessor (ClusterIP) 预计 HTTP/8118 上的流量。

通过上述设置,当我浏览到我的 Ingress-Gateway 的外部 IP 时,首先我收到一个证书错误(预计我正在使用自签名进行测试),然后继续我收到 HTTP 错误 503 .

我无法在网关中找到任何有用的日志,我想知道网关是否无法以纯文本方式与我的 VirtualService 通信(TLS 终止)并且它需要 https,但我已将其设置为 http? 非常感谢任何帮助,我对 Istio 还很陌生,我想我可能在这里遗漏了一些幼稚的东西。

我的期望是:我应该能够使用 https 访问网关,网关执行终止并将未加密的流量转发到仅基于 URL 正则表达式匹配的 HTTP 端口上的 VirtualService 中配置的目标(我必须保持 URL 匹配部分不变)。

【问题讨论】:

  • 网关看起来不错,如果我正确理解文档,那么 ignoreUriCase: true 将无法使用 queryParamas,只能使用 uri。我不知道那个 commerce-mesh-port 目的地规则是干什么用的?您能否尝试为您的虚拟服务添加destination ruletrafficPolicy: tls: mode: SIMPLE,如documentation 中所述?
  • 感谢@jt97 的回复。我确实尝试为默认命名空间中的所有主机创建一个模式为 SIMPLE 的新目标规则,但没有奏效。我什至尝试过禁用,但它也不起作用。我认为 commerce-mesh-port 必须与 kube api 服务器联系,因为它可能来自端口号 16443,但不确定。最后,我删除了任何与 ISTIO_MUTUAL 相关的 ServiceEntry/DestinationRule 并再次尝试但没有运气:( 仍然收到 503 错误。
  • 你说的ServiceEntry,是指虚拟服务?或者您是否使用服务入口并且您的应用程序不在网格中?如here 所述,您的服务名称是否正确?您可以尝试先部署目标规则,然后再部署虚拟服务吗?您是否使用 istio-injection=enabled 标记命名空间?您可以尝试安装bookinfo app 并检查它是否有效吗?
  • 我看到@Jakub 发布的答案对您有所帮助,请考虑支持/接受它,以便其他用户可以看到它很有用。请参考What should I do when someone answers my question?

标签: http kubernetes istio azure-aks


【解决方案1】:

由于 503 经常发生并且很难找到我设置的小故障排除答案的问题,还有另一个问题与 503 错误,我遇到了几个月的答案,来自 istio 文档的有用信息和我会检查的东西。

503 错误示例:

istio 文档中出现 503 错误的常见原因:

我会先检查几件事:

  • 检查服务端口名称,如果 Istio 知道协议,它可以正确路由流量。应该是&lt;protocol&gt;[-&lt;suffix&gt;],如istio documentation 中所述。
  • 检查mTLS,如果mTLS有问题,一般会报503错误。
  • 检查 istio 是否正常工作,我建议应用 bookinfo application 示例并检查它是否按预期工作。
  • 检查您的命名空间是否为injectedkubectl get namespace -L istio-injection
  • 如果使用子集的 VirtualService 在定义子集的 DestinationRule 之前到达,Pilot 生成的 Envoy 配置将引用不存在的上游池。这会导致 HTTP 503 错误,直到所有配置对象都可供 Pilot 使用。

希望你觉得这很有用。

【讨论】:

  • 感谢@jt97的详细回复,我验证了你提到的几点: 1.服务端口正确命名。 -> Looks Fine 2. mTLS 在默认命名空间中全局启用,DestinationRule 的流量策略为 ISTIO_MUTUAL。 -> 看起来不错 3. 为 istio-injection 启用了命名空间 -> 看起来不错 4. 还没有子集,因此没有定义子集的 DestinationRules -> 看起来不错 我仍在查看任何其他冲突的策略。跨度>
猜你喜欢
  • 1970-01-01
  • 2020-07-19
  • 1970-01-01
  • 2019-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多