安裝依附工具並驗證叢集
Google Cloud 詳情請參閱「Cloud Service Mesh 總覽」一文。本頁說明如何準備環境和叢集,以便為 Kubernetes 工作負載安裝叢內 Cloud Service Mesh Google Cloud。
安裝必要工具
您可以在 Cloud Shell 或執行 Linux 的本機電腦上執行 asmcli
。Cloud Shell 會預先安裝所有必要工具。
如果您在asmcli
本機執行,請確認已安裝下列工具:
- Google Cloud CLI
- 標準指令列工具:
awk
、curl
、grep
、sed
和tr
git
kubectl
jq
- (選用,用於測試連線) 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.26.4
curl https://storage.googleapis.com/csm-artifacts/asm/asmcli_1.26 > 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 (僅限軟體)、GKE on AWS (已淘汰)、GKE on Azure (已淘汰)、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
--kubeconfig
kubeconfig
的路徑。您可以指定相對路徑或完整路徑。環境變數$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