瞭解 Cloud Service Mesh 相容性

ISTIOD 控制層實作已淘汰,您必須評估相容性、解決機群中的阻礙條件,並在支援終止期限前完成現代化。

本指南將詳細說明如何評估機群是否與控制層現代化相容,方法是確認其設定、基礎架構和規模與 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

機群層級相容性

在 state.servicemesh.conditions 下方,查看機群的整體現代化狀態。

  • 機群相容:如果機群相容,您會看到代碼為 MODERNIZATION_COMPATIBLE 的條件:

    name: projects/project_id/locations/global/features/servicemesh
    state:
      servicemesh:
        conditions:
        - code: MODERNIZATION_COMPATIBLE
          details: 'Fleet is eligible for modernization.'
          documentationLink: https://cloud.google.com/service-mesh/...
          severity: INFO
    
  • 機群不相容:如果機群尚未與現代化功能相容,您會看到代碼為 MODERNIZATION_INCOMPATIBLE 的條件:

    name: projects/project_id/locations/global/features/servicemesh
    state:
      servicemesh:
        conditions:
        - code: MODERNIZATION_INCOMPATIBLE
          details: 'Fleet is not yet eligible for modernization.'
          documentationLink: https://cloud.google.com/service-mesh/...
          severity: INFO
    

    如果機群不相容,請查看特定差距的條件。請檢查 membershipStates.servicemesh 下是否有其他 WARNING 或 ERROR 嚴重程度的機群層級條件,以及叢集層級條件,並解決所有阻礙。

叢集層級相容性

在機群中,針對每個已佈建 Cloud Service Mesh 的叢集,在 membershipStates.servicemesh 下方尋找嚴重性為 WARNING 或 ERROR 的條件。如果存在不相容問題,輸出內容會類似如下:

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 註解。

以下是 gcloud container fleet mesh describe 指令的輸出範例,其中成員資格設有 MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION 條件:

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. 修改 Deployment 或 Pod 的 YAML 規格,確保只使用支援的註解 (不支援所有其他註解)。移除所有不支援的註解、更正無效值,然後將更新後的 YAML 重新套用至叢集。
    2. 修正所有 Pod 註解後,該成員資格就不會再顯示 MODERNIZATION_INCOMPATIBLE_POD_ANNOTATION 條件。

解決不相容的設定

MODERNIZATION_INCOMPATIBLE_CONFIG 程式碼表示叢集設定不相容,因此無法現代化至 TRAFFIC_DIRECTOR 控制層。不相容的原因可能包括:

  • 特定 Istio 自訂資源 (CR) 使用不支援的功能或欄位,或含有無效值。
  • Istio MeshConfig 設定無效或不受支援。
  • 超過擴充性限制。
  • 使用不支援的服務或命名空間註解。

以下是 gcloud container fleet mesh describe 指令的輸出範例,其中成員資格設有 MODERNIZATION_INCOMPATIBLE_CONFIG 條件:

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 問題,並檢查 Gateway 和 ServiceEntry 資源是否有錯誤。

  2. 找出並調查不相容的資源:使用下列範例指令碼,列出未通過相容性檢查的 Istio 自訂資源 (CR)。這個指令碼僅供參考,請先檢查並分析,確保符合您的環境和作業需求,再於叢集中執行。指令碼需要安裝 kubectl 和 jq。輸出內容包含在每項資源的 status.conditions (類型:ModernizationCompatible,狀態:"False") 下找到的特定錯誤詳細資料。

    for resource in authorizationpolicies destinationrules envoyfilters gateways peerauthentications proxyconfigs 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 支援的功能」和「代管 Cloud Service Mesh 的 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 條件。

解決不相容的機群規模

MODERNIZATION_INCOMPATIBLE_FLEET_SCALE 程式碼表示機群無法翻新至 TRAFFIC_DIRECTOR 控制層,因為機群中的資源規模超出翻新支援的限制。

在這個階段,我們支援現代化機群,但有下列限制: