排解車隊層級設定問題

本文提供 GKE Identity Service 機群層級設定的疑難排解說明。

解決車隊層級設定問題

如要解決設定車隊時可能發生的問題,請按照下列操作說明進行:

1. 驗證是否已啟用 GKE Identity Service

如要驗證專案是否已啟用 GKE Identity Service,請執行下列指令:

$ gcloud container fleet identity-service describe

如果沒有看到任何錯誤,表示 GKE Identity Service 已啟用,您可以繼續執行下一個指令

錯誤: Identity Service Feature for project <your-project-id> is not enabled

如果看到這個錯誤,表示設定這項功能時,您未正確為車隊啟用 GKE Identity Service。

解決方案: 如要確保專案已啟用這項功能,請參閱「為 GKE Identity Service 設定叢集」一文中的操作說明。

2. 查看 GKE Identity Service 狀態

如要查看 GKE Identity Service 的目前狀態,請執行下列指令:

$ gcloud container fleet identity-service describe

這項指令的輸出內容包含下列兩個部分:

  • membershipSpecs 包含您為註冊至機群的每個叢集指定的 IDP 設定。系統會使用這些設定,在每個叢集上設定 GKE Identity Service。

  • membershipStates 顯示每個叢集中的 GKE Identity Service 目前狀態,包括相關的 IDP 設定,以及設定期間可能發生的任何錯誤。

如要排解叢集中的問題,請在 membershipStates 下方搜尋叢集,然後查看下列欄位:

  • state 欄位:membershipStates -> <cluster-identifier> -> identityservice -> state
  • failureReason 欄位:membershipStates -> <cluster-identifier> -> identityservice -> failureReason

範例

如果機群中註冊了兩個叢集 helloworldfoobar,輸出內容的結構如下:

Identity Service Feature:
  createTime: '222-11-10T23:05:6.146566392Z'
  membershipSpecs:
    projects/<your-project-number>/locations/<location>/memberships/helloworld:
      identityservice:
        authMethods:
        - name: oidc
          oidcConfig:
            clientId: id
            issuerUri: https://accounts.google.com
            ... other fields
    projects/<your-project-number>/locations/<location>/memberships/foobar:
      identityservice:
        authMethods:
        - name: oidc
          oidcConfig:
            clientId: id
            issuerUri: https://accounts.google.com
            ... other fields 
  membershipStates:
    projects/<your-project-number>/location/<location>/memberships/helloworld:
      identityservice:
        failureReason: AIS feature does not support this cluster type
        memberConfig:
          authMethods:
          - name: oidc
            oidcConfig:
              clientId: id
              issuerUri: https://accounts.google.com
              ... other fields
        state: ERROR
      state:
        code: OK
        updateTime: '2022-11-11T20:39:59.556176650Z'
    projects/<your-project-number>/location/<location>/memberships/foobar:
      identityservice:
        memberConfig:
          authMethods:
          - name: oidc
            oidcConfig:
              clientId: id
              issuerUri: https://accounts.google.com
              ... other fields
        state: OK
      state:
        code: OK
        updateTime: '2022-11-11T20:39:59.556176650Z'

  name: projects/<project-number>/locations/global/features/identityservice
  updateTime: '2022-11-11T20:40:31.859321901Z'

3. 驗證叢集狀態

如要驗證叢集中的 GKE Identity Service 狀態,請檢查下列項目:

  • state 值為 OK:這表示在叢集上設定 GKE Identity Service 時,沒有發生任何錯誤,且設定是根據 membershipSpecs 指定的設定。

    如果您要排解叢集 (例如 helloworld) 的問題,但 membershipSpecsmembershipStates 中的設定不同,則可能是您更新了叢集的設定。請稍候幾分鐘,讓 GKE Identity Service 將變更傳播至叢集,然後再次檢查狀態

    如果所要排解問題的叢集 (例如 helloworld) 在 membershipSpecsmembershipStates 中的設定相同,表示 GKE Identity Service 設定正確。

  • state 欄位為 ERROR:這表示在叢集上設定 GKE Identity Service 時發生錯誤,設定是根據 membershipSpecs 指定的內容。

    如要解決這個問題,請參閱「排解常見問題」。 完成必要的疑難排解步驟後,請稍候幾分鐘,然後再次檢查狀態

排解常見問題

未啟用 GKE Identity Service API

如果未啟用 GKE Identity Service API,就會發生這個問題。

錯誤訊息

anthosidentityservice.googleapis.com is not enabled

解決方案

如要啟用 API,請執行下列指令:

$ gcloud services enable anthosidentityservice.googleapis.com

不支援的叢集類型

如果使用不支援的叢集類型,就會發生這個問題。

錯誤訊息

GKE Identity Service feature does not support this cluster type

解決方案

如要瞭解支援的叢集類型,請參閱「叢集類型」,或向 Google Cloud 支援團隊提出新的叢集類型要求。

設定中含有不支援的通訊協定

如果套用至叢集的 ID 設定包含不支援的通訊協定,就會發生這個問題。

錯誤訊息

unsupported protocol found in configuration, aborting reconciliation.

解決方案

GKE Identity Service 的機群層級設定支援下列項目:

更新叢集上的設定,使其只包含上述支援的通訊協定。如要編輯設定,請執行下列指令:

kubectl --kubeconfig CLUSTER_KUBECONFIG -n kube-public edit clientconfig default

請將 CLUSTER_KUBECONFIG 替換為叢集的 kubeconfig 檔案路徑。如果 kubeconfig 中有多個環境,系統會使用目前的環境。您可能需要將目前的背景資訊重設為正確的叢集,才能執行指令。

叢集沒有身分識別設定

如果叢集未套用任何設定,就會發生這個問題。

錯誤訊息

Authentication configuration is not present for this membership

解決方案

按照「設定叢集」一文中的操作說明,將身分設定套用至叢集。

缺少 GKE Hub 管理員 IAM 權限

如果使用的專案沒有 gkehub.admin 角色,就會發生這個問題。

錯誤訊息

PERMISSION_DENIED: Permission 'gkehub.memberships.list' denied on '`projects//locations//memberships`'
PERMISSION_DENIED: Permission 'gkehub.features.get' denied on '`projects//locations/global/features/identityservice`'
PERMISSION_DENIED: Permission 'gkehub.features.delete' denied on '`projects//locations/global/features/identityservice`'
PERMISSION_DENIED: Permission 'gkehub.features.create' denied on '`projects//locations/global/features/identityservice`'

解決方案

專案 ID 為 project_id 的專案擁有者必須執行下列指令:

gcloud projects add-iam-policy-binding project_id --member=user:USER_ID --role=roles/gkehub.admin

USER_ID 替換為您的 Google 帳戶。

身分設定中出現非專屬識別資訊提供者

如果叢集的 GKE Identity Service 設定中,多個身分識別提供者具有相同的 name 值,就會發生這個問題。

錯誤訊息

Configuration contains multiple identity providers with the same name

解決方案

重新命名或移除設定中的重複項目。

身分設定中存在多個 google 類型提供者

如果 ClientConfig 設定了多個 google 類型的設定,就會發生這個問題。

錯誤訊息

configuration contains multiple identity providers of type 'google'

解決方案

設定的 spec/authentication 區段最多只能包含一個 google 類型的設定。

更新叢集設定,確保叢集最多只有一個 google 類型的設定。如要編輯設定,請執行下列指令:

kubectl --kubeconfig CLUSTER_KUBECONFIG -n kube-public edit clientconfig default

請將 CLUSTER_KUBECONFIG 替換為叢集的 kubeconfig 檔案路徑。如果 kubeconfig 中有多個環境,系統會使用目前的環境。您可能需要將目前的背景資訊重設為正確的叢集,才能執行指令。

擷取 ClientConfig 的自訂資源定義時發生錯誤

從叢集擷取 ClientConfig 的自訂資源定義時發生錯誤,就會發生這個問題。

錯誤訊息

error fetching the ClientConfig's Custom Resource Definition: ERROR_REASON

解決方案

請使用 ERROR_REASON 中顯示的詳細資料解決這個問題。

更新 GKE Identity Service ClientConfig 時發生錯誤

如果更新叢集中的 ClientConfig 時發生錯誤,就會發生這個問題。

錯誤訊息

Error updating AIS ClientConfig: ERROR_REASON

解決方案

請使用 ERROR_REASON> 中顯示的詳細資料解決這個問題。

叢集上沒有 ClientConfig

如果叢集上沒有 ClientConfig (應在安裝 GKE Identity Service 時建立),就會發生這個問題。如果缺少 ClientConfig,表示 GKE Identity Service 未正確安裝在叢集上。

錯誤訊息

ClientConfig CR not present, expected to be created when AIS was installed

解決方案

叢集上的 GKE Identity Service 資源可能遭到誤刪。您可以嘗試建立新的叢集。如果新叢集也出現相同錯誤,請與叢集管理員或 Google Cloud 支援團隊聯絡。

GKE Identity Service Pod 未啟動

如果 GKE Identity Service Pod 處於 pending 狀態,就會發生這個問題。

錯誤訊息

GKE Identity Service pod is not running (pending)

解決方案

這個問題應會在幾分鐘內自動解決,屆時 GKE Identity Service Pod 會切換至 running 狀態。