了解 Cloud Service Mesh 兼容性

本指南详细介绍了如何评估舰队在控制平面现代化方面的兼容性,方法是确认其配置、基础架构和规模是否与 TRAFFIC_DIRECTOR 控制平面实现兼容。

选择启用或停用兼容性检查

如需启动兼容性检查,请为舰队启用验证模式,这会触发对所有 Istio 配置、基础架构配置和扩缩参数的持续审核。启用这些检查不会对您的舰队或集群进行任何更改,只会启用兼容性报告。

启用检查

如需开始进行兼容性审核,请运行以下 gcloud 命令:

gcloud alpha container fleet mesh update --modernization-compatibility validation-enabled --project FLEET_PROJECT_ID

FLEET_PROJECT_ID 替换为您的舰队宿主项目的 ID。 通常,FLEET_PROJECT_ID 与项目的名称相同。

启用后,Cloud Service Mesh 会开始评估舰队和舰队中所有已预配 Cloud Service Mesh 的集群,以确定它们是否兼容现代化。

停用检查

如需停止报告兼容性结果,请运行以下命令:

gcloud alpha container fleet mesh update --modernization-compatibility validation-disabled --project FLEET_PROJECT_ID

此命令会从成员资格状态中移除现代化兼容性条件,并从各个 Istio CR 中移除 ModernizationCompatible 状态。

了解兼容性

现代化改造兼容性通过舰队和成员(集群)级层的条件进行报告。系统会在不同时间执行各种检查,所有检查每天至少运行一次。启用检查或应用修复后,状态最多可能需要一天时间才能更新。

如需查看这些结果,请使用以下命令检索最新的网状网络状态:

gcloud container fleet mesh describe --project FLEET_PROJECT_ID

集群级兼容性

在舰队中,针对每个已配置 Cloud Service Mesh 的集群,在 membershipStates.servicemesh 下查找严重程度为 WARNINGERROR 的状况。如果存在不兼容问题,则输出类似于以下内容:

membershipSpecs:
 projects/project_id/locations/global/memberships/cluster-a:
   mesh:
     management:MANAGEMENT_AUTOMATIC
membershipStates:
  projects/project_id/locations/global/memberships/cluster-a:
    servicemesh:
      conditions:
     - code: MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION
       details: 'Pod pod-a in namespace test-namespace: invalid annotations: ["status.sidecar.istio.io/port": failed to parse port - "invalid", port must be a number and should be in the range 1..65535]; unsupported annotations: ["ambient.istio.io/redirection"] .'
       documentationLink: https://cloud.google.com/service-mesh/...
       severity: WARNING
     - code: WORKLOAD_IDENTITY_REQUIRED
       details: 'Workload Identity is not enabled for the cluster or at least one of the node pools.'
       documentationLink: https://cloud.google.com/...
       severity: ERROR
...

按照每种条件中提供的 documentationLink 了解并解决具体的不兼容问题。

解决兼容性问题

解决不兼容的 pod 注释

MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION 代码表示集群无法升级到 TRAFFIC_DIRECTOR 控制平面,因为某些 Pod 具有不受支持或无效的 Istio 注释。

为会员设置了 MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION 条件的 gcloud container fleet mesh describe 命令的输出示例:

membershipStates:
  projects/project_id/locations/global/memberships/membership-a:
    servicemesh:
      conditions:
     - code: MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION
       details: 'Pod pod-a in namespace test-namespace: invalid annotations: ["status.sidecar.istio.io/port": failed to parse port - "invalid", port must be a number and should be in the range 1..65535]; unsupported annotations: ["ambient.istio.io/redirection"] .'
       documentationLink: https://cloud.google.com/service-mesh/...
       severity: WARNING

如需解决这些 pod 注释问题,请执行以下操作:

  1. 识别有问题的注解:检查状态条件的 details 字段,找到不受支持或无效的注解键。查找具有问题注解键的所有 Pod。

  2. 修复并验证

    1. 修改部署或 Pod 的 YAML 规范,以移除或修改已识别的注释,确保它们不包含任何不受支持的注释。将更新后的 YAML 重新应用到集群。
    2. 更正所有 Pod 注释后,相应会员资格将不再显示 MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION 条件。

解决不兼容的配置

MODERNIZATION_INCOMPATIBLE_CONFIG 代码表示由于配置不兼容,集群无法现代化为 TRAFFIC_DIRECTOR 控制平面。这些不兼容问题可能源于:

  • 使用不受支持的功能或字段或包含无效值的特定 Istio 自定义资源 (CR)。
  • 无效或不受支持的 Istio MeshConfig 设置。
  • 超出可伸缩性限制。
  • 使用不受支持的服务或命名空间注释。

为会员设置了 MODERNIZATION_INCOMPATIBLE_CONFIG 条件的 gcloud container fleet mesh describe 命令的输出示例:

membershipSpecs:
 projects/project_id/locations/global/memberships/membership-a:
   mesh:
     management:MANAGEMENT_AUTOMATIC
membershipStates:
  projects/project_id/locations/global/memberships/membership-a:
    servicemesh:
      conditions:
     - code: MODERNIZATION_INCOMPATIBLE_CONFIG
       details: 'One or more configs have warnings. Due to the following reason(s): Istio sidecar scale exceeds limit, MeshConfig "accessLogFile" is unsupported. Invalid Config Types: [Gateway, ServiceEntry], where more details are shown on individual config resources.See documentation link for more detail.'
       documentationLink: https://cloud.google.com/service-mesh/...
       severity: WARNING

如需解决这些配置问题,请执行以下操作:

  1. 分析条件详情:检查状态条件的 details 字段。它会汇总各个错误,并找出存在配置问题的资源类型。对于所提供的详细信息示例,您需要解决规模和 MeshConfig 问题,并检查 GatewayServiceEntry 资源是否存在错误。

  2. 识别并调查不兼容的资源:使用以下脚本列出所有未通过兼容性检查的 Istio 自定义资源 (CR)。该脚本需要安装 kubectljq。 输出内容包括每个资源的 status.conditions(类型:ModernizationCompatible,状态:"False")下的具体错误详情。

    for resource in authorizationpolicies destinationrules gateways proxyconfigs peerauthentications requestauthentications serviceentries sidecars telemetries virtualservices wasmplugins workloadentries workloadgroups; do
      echo "--- Checking $resource ---"
      kubectl get $resource --all-namespaces -o json | \
      jq -r '.items[] | select(.status.conditions != null and any(.status.conditions[]; .type == "ModernizationCompatible" and .status == "False")) | {"kind": .kind, "name": .metadata.name, "namespace": .metadata.namespace, "message": [.status.conditions[] | select(.type == "ModernizationCompatible").message]}'
    done
    

    输出示例:

    --- Checking serviceentries ---
    {
      "kind": "ServiceEntry",
      "name": "demo-service-entry",
      "namespace": "se",
      "message": [
        "WARNING: unsupported resolution type: DNS_ROUND_ROBIN"
      ]
    }
    ..
    --- Checking workloadentries ---
    {
      "kind": "WorkloadEntry",
      "name": "demo-we",
      "namespace": "default",
      "message": [
        "WARNING: This API is not supported"
      ]
    }
    
  3. 修复并应用配置:修改 YAML,移除不受支持的字段或将无效值替换为兼容的值。如需帮助,请参阅托管式 Cloud Service Mesh 支持的功能不受支持的 Istio API 文档。(例如,在提供的示例中,将 ServiceEntry 分辨率从 DNS_ROUND_ROBIN 更新为 DNS)。

  4. 验证修复:应用修复后,请等待最多 24 小时,以便定期检查更新状态。

    • 固定资源上的 ModernizationCompatible 条件应更改为状态:"True"。使用以下命令检查资源的状态:

      kubectl get resource name -n namespace -o yaml
      

      输出示例:

      status:
        conditions:
        - lastTransitionTime: "2026-06-05T06:12:52.219963391Z"
          message: Resource is compatible for modernization
          reason: Compatible
          status: "True"
          type: ModernizationCompatible
      
    • 重新运行 gcloud container fleet mesh describe 命令。所有相关问题解决后,相应会员资格将不再显示MODERNIZATION_INCOMPATIBLE_CONFIG条件。