安裝依附工具並驗證叢集
本頁面說明如何準備環境和叢集,以便為 Kubernetes 工作負載安裝叢集內的 Cloud Service Mesh。 Google Cloud
安裝必要工具
您可以在 Cloud Shell 或執行 Linux 的本機電腦上執行 asmcli。Cloud Shell 會預先安裝所有必要工具。
如果您在本機執行 asmcli,請務必安裝下列工具:
- Google Cloud CLI
- 標準指令列工具:
awk、curl、grep、sed和tr gitkubectljq- (選用,用於測試連線) netcat (
nc)
設定 gcloud
即使您使用的是 Cloud Shell,也請執行下列步驟。
使用 Google Cloud CLI 進行驗證:
gcloud auth login --project PROJECT_ID更新元件:
gcloud components update
將目前的結構定義設為使用者叢集:
根據平台專屬的操作說明,將 kubectl 背景資訊設為指向離線Google Cloud 叢集。
下載 asmcli
本節說明如何下載 asmcli。
下載將 Cloud Service Mesh 1.21.5 安裝至目前工作目錄的版本:
curl https://storage.googleapis.com/csm-artifacts/asm/asmcli_1.21 > asmcli預期輸出內容:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 167k 100 167k 0 0 701k 0 --:--:-- --:--:-- --:--:-- 701k將指令碼設定為可執行:
chmod +x asmcli
授予叢集管理員權限
請確認您已將背景資訊設為使用者叢集:
kubectl config use-context CONTEXT
將叢集管理員權限授予您的使用者帳戶 ( Google Cloud 登入電子郵件地址)。您需要這些權限來為 Cloud Service Mesh 建立必要的角色型存取控制 (RBAC) 規則:
kubectl create clusterrolebinding cluster-admin-binding \ --clusterrole=cluster-admin \ --user=USER_ACCOUNT
驗證專案和叢集
您可以執行 asmcli validate,確認專案和叢集已依據安裝 Cloud Service Mesh 的必要條件進行設定。選用這個選項後,asmcli 不會對專案或叢集進行任何變更,也不會安裝 Cloud Service Mesh。
asmcli 會驗證:
環境中具備必要工具。
叢集符合最低需求。
您在指定專案中具備必要權限。
專案已啟用所有必要的 Google API。
根據預設,asmcli 會下載及解壓縮安裝檔案,並從 GitHub 下載 asm 設定套件至暫存目錄。結束前,asmcli 會輸出訊息,提供暫存資料夾的名稱。建議您使用 --output_dir DIR_PATH 選項指定下載檔案的目錄。--output_dir 選項可讓您輕鬆使用 istioctl 指令列工具。您可能需要使用 istioctl 來排解設定相關問題。此外,asm/istio/options 目錄中也包含使用 asmcli 啟用選用功能的設定檔。
執行下列指令,驗證設定,並將安裝檔案和 asm 套件下載至 OUTPUT_DIR 目錄。
使用下列指令,在下列平台上執行 asmcli validate:VMware 適用的 Google Distributed Cloud (僅限軟體)、裸機適用的 Google Distributed Cloud (僅限軟體)、AWS 上的 GKE、Azure 上的 GKE、Amazon EKS 和 Microsoft AKS。
將目前的結構定義設為使用者叢集:
kubectl config use-context CLUSTER_NAME執行下列指令,驗證設定,並將安裝檔案和
asm套件下載至OUTPUT_DIR目錄:./asmcli validate \ --kubeconfig KUBECONFIG_FILE \ --fleet_id FLEET_PROJECT_ID \ --output_dir DIR_PATH \ --platform multicloud--kubeconfigkubeconfig的路徑。您可以指定相對路徑或完整路徑。環境變數$PWD在這裡無效。--fleet_id機群主機專案的專案 ID。asmcli validate會檢查叢集是否已註冊至指定的機群。--output_dir加入這個選項,即可指定asmcli下載asm套件並擷取安裝檔案的目錄,其中包含istioctl、範例和資訊清單。否則,asmcli會將檔案下載至tmp目錄。您可以指定相對路徑或完整路徑。環境變數$PWD在這裡無效。--platform multicloud指定平台不是 Google Cloud,例如內部部署環境或多雲端。
成功後,asmcli 會輸出以下內容:
asmcli: Setting up necessary files... asmcli: Using asm_kubeconfig as the kubeconfig... asmcli: Checking installation tool dependencies... asmcli: Fetching/writing GCP credentials to kubeconfig file... asmcli: Verifying connectivity (10s)... asmcli: kubeconfig set to asm_kubeconfig asmcli: using context gke_example-project-12345_us-central1_cluster-2 asmcli: Getting account information... asmcli: Downloading ASM.. asmcli: Downloading ASM kpt package... fetching package "/asm" from "https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages" to "asm" asmcli: Checking required APIs... asmcli: Checking for project example-project-12345... asmcli: Reading labels for us-central1/cluster-2... asmcli: Checking for istio-system namespace... asmcli: Confirming node pool requirements for example-project-12345/us-central1/cluster-2... asmcli: Checking Istio installations... asmcli: [WARNING]: There is no way to validate that the meshconfig API has been initialized. asmcli: [WARNING]: This needs to happen once per GCP project. If the API has not been initialized asmcli: [WARNING]: for example-project-12345, please re-run this tool with the --enable_gcp_components asmcli: [WARNING]: flag. Otherwise, installation will succeed but Anthos Service Mesh asmcli: [WARNING]: will not function correctly. asmcli: Successfully validated all requirements to install ASM.
如果其中一個測試失敗,asmcli 就會輸出錯誤訊息。舉例來說,如果您的專案未啟用所有必要的 Google API,您會看到以下錯誤:
ERROR: One or more APIs are not enabled. Please enable them and retry, or run `asmcli` with the '--enable_gcp_apis' flag to allow `asmcli` to enable them on your behalf.
如果您收到錯誤訊息,指出需要使用啟用標記執行 asmcli,您可以選擇下列任一做法:
執行
asmcli進行實際安裝時,請加入錯誤訊息中的特定標記或--enable_all標記。如有需要,您可以在執行
asmcli前自行更新專案和叢集,如自行設定專案和 GKE 叢集所述。
請注意,asmcli validate 不允許任何啟用旗標,因為它只會驗證專案和叢集是否已準備好進行安裝。
檢查叢集安裝和升級需求
升級前,請確認設定是否與新版 Cloud Service Mesh 相容。
變更至您在
--output_dir中指定的目錄。執行下列指令,檢查 Kubernetes 叢集的安裝和升級需求。請務必使用與新版 Cloud Service Mesh 版本分發的
istioctl版本。istioctl experimental precheck