需要帮助解决 Istio IngressGateway HTTP 错误 503
Need help troubleshooting Istio IngressGateway HTTP ERROR 503
我的测试环境集群有以下配置:
全局网格策略(由我们的组织作为集群设置的一部分安装):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 流量(在简单模式下配置)
接下来,我在同一个命名空间中配置了我的 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
服务 CommercialProcessor (ClusterIP) 预计 HTTP/8118 上的流量。
通过上述设置,当我浏览到我的 Ingress-Gateway 的外部 IP 时,首先我收到一个证书错误(因为我正在使用自签名进行测试,这是预期的)然后继续我得到 HTTP错误 503。
我无法在网关中找到任何有用的日志,我想知道网关是否无法以纯文本(TLS 终止)与我的 VirtualService 通信并且它期待 https 但我将其设置为 http?
非常感谢任何帮助,我是 Istio 的新手,我想我可能在这里遗漏了一些天真的东西。
我的期望是:我应该能够使用 https 访问网关,网关会终止并将未加密的流量转发到基于 URL 正则表达式匹配的 HTTP 端口上的虚拟服务中配置的目的地(我必须在这里保持 URL 匹配部分不变。
由于 503 经常发生并且很难找到问题我设置了很少的故障排除答案,还有另一个问题与 503 错误我遇到了几个月的答案,来自 istio 文档的有用信息和我会做的事情检查。
503 错误示例:
- Istio 503:s between (Public) Gateway and Service
istio 文档中 503 错误的常见原因:
- https://istio.io/docs/ops/best-practices/traffic-management/#avoid-503-errors-while-reconfiguring-service-routes
- https://istio.io/docs/ops/common-problems/network-issues/#503-errors-after-setting-destination-rule
- https://istio.io/latest/docs/concepts/traffic-management/#working-with-your-applications
我首先要检查的几件事:
- 检查服务端口名称,如果 Istio 知道协议,它可以正确路由流量。它应该是
<protocol>[-<suffix>]
如 istio 中所述
文档.
- 检查mTLS,如果mTLS有任何问题,通常这些问题会导致错误503。
- 检查 istio 是否工作,我建议应用 bookinfo application 示例并检查它是否按预期工作。
- 检查您的命名空间是否为 injected 和
kubectl get namespace -L istio-injection
- 如果使用子集的 VirtualService 在定义子集的 DestinationRule 之前到达,则 Pilot 生成的 Envoy 配置将引用 non-existent 上游池。这会导致 HTTP 503 错误,直到所有配置对象都可用于 Pilot。
希望你觉得这有用。
我的测试环境集群有以下配置:
全局网格策略(由我们的组织作为集群设置的一部分安装):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 流量(在简单模式下配置)
接下来,我在同一个命名空间中配置了我的 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
服务 CommercialProcessor (ClusterIP) 预计 HTTP/8118 上的流量。
通过上述设置,当我浏览到我的 Ingress-Gateway 的外部 IP 时,首先我收到一个证书错误(因为我正在使用自签名进行测试,这是预期的)然后继续我得到 HTTP错误 503。
我无法在网关中找到任何有用的日志,我想知道网关是否无法以纯文本(TLS 终止)与我的 VirtualService 通信并且它期待 https 但我将其设置为 http? 非常感谢任何帮助,我是 Istio 的新手,我想我可能在这里遗漏了一些天真的东西。
我的期望是:我应该能够使用 https 访问网关,网关会终止并将未加密的流量转发到基于 URL 正则表达式匹配的 HTTP 端口上的虚拟服务中配置的目的地(我必须在这里保持 URL 匹配部分不变。
由于 503 经常发生并且很难找到问题我设置了很少的故障排除答案,还有另一个问题与 503 错误我遇到了几个月的答案,来自 istio 文档的有用信息和我会做的事情检查。
503 错误示例:
- Istio 503:s between (Public) Gateway and Service
istio 文档中 503 错误的常见原因:
- https://istio.io/docs/ops/best-practices/traffic-management/#avoid-503-errors-while-reconfiguring-service-routes
- https://istio.io/docs/ops/common-problems/network-issues/#503-errors-after-setting-destination-rule
- https://istio.io/latest/docs/concepts/traffic-management/#working-with-your-applications
我首先要检查的几件事:
- 检查服务端口名称,如果 Istio 知道协议,它可以正确路由流量。它应该是
<protocol>[-<suffix>]
如 istio 中所述 文档. - 检查mTLS,如果mTLS有任何问题,通常这些问题会导致错误503。
- 检查 istio 是否工作,我建议应用 bookinfo application 示例并检查它是否按预期工作。
- 检查您的命名空间是否为 injected 和
kubectl get namespace -L istio-injection
- 如果使用子集的 VirtualService 在定义子集的 DestinationRule 之前到达,则 Pilot 生成的 Envoy 配置将引用 non-existent 上游池。这会导致 HTTP 503 错误,直到所有配置对象都可用于 Pilot。
希望你觉得这有用。