实例配置相关诊断项说明

ASM提供了对Istio配置状态的详细分析,以便标识无效或次优的配置。本文介绍此分析可能产生的实例配置相关的错误或警告消息的详细说明。

IST0101: 引用资源未找到

消息名称

消息代码

等级

描述

ReferencedResourceNotFound

IST0101

Error

被引用的资源不存在。

当 Istio 资源引用另一个不存在的资源时,会出现此消息。 这会导致 Istio 尝试查找引用的资源但找不到这类的错误。

异常示例

在以下例子中,VirtualService 指向了一个不存在的网关:

apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: httpbin-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http2
      protocol: HTTP2
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
  - "*"
  gateways:
  - httpbin-gateway-bogus # 应该是 "httpbin-gateway"
  http:
  - route:
    - destination:
        host: httpbin-gateway

您会收到这个消息:

Error [IST0101] (VirtualService httpbin.default) Referenced gateway not found: "httpbin-gateway-bogus"

修复方式

请在详细的错误消息中找到资源类型,修正 Istio 配置并重试。

IST0109: Sidecar虚拟服务路由规则冲突

消息名称

消息代码

等级

描述

ConflictingMeshGatewayVirtualServiceHosts

IST0109

Error

与网格网关关联的虚拟服务中存在冲突的主机。

当 Istio 检测到因 VirtualService 资源重复而导致冲突时,会出现此消息。比如,多个 VirtualService 使用相同的主机名且连接网格 Gateway 时, 会出现一条错误消息。需要注意的是,Istio 支持合并挂接到入口网关的 VirtualService。

异常示例

以下示例中,命名空间 team1 的 VirtualService productpage 与命名空间 team2 的 VirtualService custom 存在冲突:

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: productpage
  namespace: team-1
spec:
  hosts:
  - productpage.default.svc.cluster.local
  http:
  - route:
    - destination:
        host: productpage
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: custom
  namespace: team-2
spec:
  hosts:
  - productpage.default.svc.cluster.local
  http:
  - route:
    - destination:
        host: productpage.team-2.svc.cluster.local
---
  • 因为自定义 Gateway 未被指定,所以 VirtualService 挂接到了默认的 “mesh” Gateway。

  • VirtualService 都定义了相同的主机 productpage.default.svc.cluster.local

修复方式

有以下几个方法:

  • 将冲突的 VirtualService 合并为一个

  • 连接 Gateway 的 VirtualService 使用唯一的主机名

  • 通过设置 exportTo 字段,将资源范围限定到指定的命名空间。例如

    apiVersion: networking.istio.io/v1
    kind: VirtualService
    metadata:
      name: productpage
      namespace: team-1
    spec:
      exportTo:
      - "."
      hosts:
      - productpage.default.svc.cluster.local
      http:
      - route:
        - destination:
            host: productpage
    ---
    apiVersion: networking.istio.io/v1
    kind: VirtualService
    metadata:
      name: custom
      namespace: team-2
    spec:
      exportTo:
      - "."
      hosts:
      - productpage.default.svc.cluster.local
      http:
      - route:
        - destination:
            host: productpage.team-2.svc.cluster.local
    ---

IST0110: Sidecar资源Workload Selector冲突

消息名称

消息代码

等级

描述

ConflictingSidecarWorkloadSelectors

IST0110

Error

某个 Sidecar 资源选择了与另一个 Sidecar 资源相同的工作负载。

当一个命名空间中有多个 Sidecar 资源选择相同的工作负载实例时会出现此消息。这可能导致未知的行为。

要解决此问题,请确保同一个命名空间中每个 Sidecar 工作负载选择器选择的工作负载实例(例如 Pod)不会重复。

IST0111: 多个Sidecar资源不包含Workload Selector

消息名称

消息代码

等级

描述

MultipleSidecarsWithoutWorkloadSelectors

IST0111

Error

命名空间中的多个 Sidecar 没有指定工作负载Selector。

当一个命名空间中有多个 Sidecar 资源没有定义任何工作负载选择器时,会出现此消息。 这种情况会造成未定义的行为。

要解决此问题,请确保每个命名空间有且仅有一个没有定义工作负载选择器的 Sidecar 资源。

IST0127: 未匹配到工作负载

消息名称

消息代码

等级

描述

NoMatchingWorkloadsFound

IST0127

Warning

资源标签中没有匹配的工作负载。

当 AuthorizationPolicy 资源的选择器匹配不到任何 Pod 时,会出现此消息。

异常示例

当集群包含以下 AuthorizationPolicy 时:

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: httpbin-nopods
  namespace: httpbin
spec:
  selector:
    matchLabels:
      app: bogus-label # 标签有误,没有匹配的工作负载
      version: v1
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/default/sa/curl"]
        - source:
            namespaces: ["httpbin"]
      to:
        - operation:
            methods: ["GET"]
            paths: ["/info*"]
        - operation:
            methods: ["POST"]
            paths: ["/data"]
      when:
        - key: request.auth.claims[iss]
          values: ["https://accounts.google.com"]

您会收到此消息:

Warning [IST0127] (AuthorizationPolicy httpbin-nopods.httpbin) No matching workloads for this resource with the following labels: app=bogus-label,version=v1

此示例中,AuthorizationPolicy 资源 httpbin-nopods 需要绑定到包含 app=bogus-label 标签的 Pod 上,但是其不存在。

修复方式

  • 修改选择器 selector 以选择存在的 Pod

  • 修改特定 Pod 的标签以匹配此资源的选择器

IST0132: 未在网关规则中定义的虚拟服务域名

消息名称

消息代码

等级

描述

VirtualServiceHostNotFoundInGateway

IST0132

Warning

虚拟服务中定义的主机未在网关中找到。

当一个 VirtualService 声明了 host 但无法找到相应的网关时,会出现此消息。

异常示例

当您的集群中包含以下 VirtualServiceGateway时:

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: testing-service
  namespace: default
spec:
  gateways:
  - istio-system/testing-gateway
  hosts:
  - wrong.com
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: ratings
---
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: testing-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - testing.com
    port:
      name: http
      number: 80
      protocol: HTTP

您将会收到以下消息:

Warning [IST0132] (VirtualService testing-service.default testing.yaml:8) one or more host [wrong.com] defined in VirtualService default/testing-service not found in Gateway istio-system/testing-gateway.

在这个示例中, VirtualService testing-service 拥有域名 wrong.com, 但是该域名没有声明在网关 testing-gateway 中。

修复方式

确保 VirtualService 中所有 hosts 都已绑定到了相应的网关 hosts 中。

IST0138: 网关规则证书重复定义

当客户端重用 HTTP/2 连接时,为多个网关配置相同的证书可能会导致 404 错误。

IST0141: 权限不足

istio 所需资源权限不足。

IST0145: 网关规则存在冲突

网关规则中存在冲突。

IST0149: 虚拟服务JWT Claim路由未定义请求身份认证

虚拟服务中基于JWT Claim的路由能力必须结合应用于网关的请求身份认证使用,否则无法起效。

IST0159: Telemetry workload selector冲突

消息名称

消息代码

等级

描述

ConflictingTelemetryWorkloadSelectors

IST0159

Error

两个遥测资源配置选择了相同的工作负载。

当同一命名空间中的多个 Telemetry 资源具有重叠的工作负载选择器时, 由于无法确定应将哪个 Telemetry 资源应用于特定 Pod, 会出现 ConflictingTelemetryWorkloadSelectors 消息。 这可能会导致受影响的工作负载的 Telemetry 配置出现意外。

满足以下条件时会生成此消息:

  1. 同一命名空间内存在多个 Telemetry 资源。

  2. 这些 Telemetry 资源具有匹配到同一组 Pod 的工作负载选择器。

修复方式

请查看冲突的 Telemetry 资源并更新其工作负载选择器, 以确保每个 Pod 仅与一个 Telemetry 资源匹配。 您可能需要调整标签选择器或重新组织 Telemetry 资源以避免选择器产生重叠。

IST0160: 多个Telemetry未定义workload selector

消息名称

消息代码

等级

描述

MultipleTelemetriesWithoutWorkloadSelectors

IST0160

Error

命名空间中多个遥测资源没有配置工作负载Selector。

当同一命名空间中有多个未定义任何工作负载选择器的 Telemetry 资源时, 会出现 MultipleTelemetriesWithoutWorkloadSelectors 消息。 如果没有任何工作负载选择器,这些 Telemetry 资源默认适用于命名空间中的所有工作负载。 拥有多个此类资源可能会导致在确定应将哪个 Telemetry 资源应用于特定 Pod 时产生歧义。

满足以下条件时会生成此消息:

  1. 同一命名空间内存在多个 Telemetry 资源。

  2. 这些 Telemetry 资源没有定义任何工作负载选择器。

修复方式

请查看冲突的 Telemetry 资源并为每个资源定义适当的工作负载选择器。 通过指定工作负载选择器,您可以确保将每个 Telemetry 资源应用于预期的 Pod 集, 从而避免遥测配置中的潜在冲突和歧义。

IST0162: 网关规则端口未开放

消息名称

消息代码

等级

描述

GatewayPortNotDefinedOnService

IST0162

Warning

网关端口没有通过Service暴露。

当 Gateway(通常是 istio-ingressgateway) 提供的端口与网关实例关联的 Kubernetes 服务(Service) 定义的端口不匹配时,GatewayPortNotDefinedOnService 消息将会出现。

异常示例

例如,您的配置定义如下:

# 端口定义错误的 Gateway

apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: istio-ingressgateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
  - port:
      number: 8004
      name: http2
      protocol: HTTP
    hosts:
    - "*"
---

# 默认的网关 Service

apiVersion: v1
kind: Service
metadata:
  name: istio-ingressgateway
spec:
  selector:
    istio: ingressgateway
  ports:
  - name: status-port
    port: 15021
    protocol: TCP
    targetPort: 15021
  - name: http2
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    port: 443
    protocol: TCP
    targetPort: 8443

在此示例中,因为配置使用了端口 8004,但默认的 IngressGateway (名称为 istio-ingressgateway)只定义了目标端口 15021、8080 和 8443, 所以 GatewayPortNotDefinedOnService 消息出现。

修复方式

请更改网关配置以使用工作负载上的有效端口,然后重试。

以下是已更正的示例:

# 端口定义正确的 Gateway

apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: istio-ingressgateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 8080
      name: http2
      protocol: HTTP
    hosts:
    - "*"
  - port:
      number: 8443
      name: https
      protocol: HTTP
    hosts:
    - "*"

IST0173: 目标规则子集未匹配Pod

目标规则中定义的子集未匹配到任何Pod。

IST0174: 未知的目标规则域名

目标规则中定义的域名在服务网格中并未定义。