使用 PowerShell 模組驗證 AKS 上的 gMSA
使用 PowerShell 模組在 AKS 上設定 gMSA 之後,您的應用程式即可部署在 AKS 上的 Windows 節點上。 不過,如果您想要進一步驗證組態是否已正確設定,您可以使用下列指示來確認部署是否已正確設定。
驗證
AKS PowerShell 模組上的 gMSA 提供命令來驗證環境設定是否正確設定。 驗證 gMSA 認證規格是否適用於下列命令:
Start-GMSACredentialSpecValidation `
-SpecName $params["gmsa-spec-name"] `
-AksWindowsNodePoolsNames $params["aks-win-node-pools-names"]
從 Windows 節點收集 gMSA 記錄
下列命令可用來從 Windows 主機擷取記錄:
# Extracts the following logs from each Windows host:
# - kubelet logs.
# - CCG (Container Credential Guard) logs (as a .evtx file).
Copy-WindowsHostsLogs -LogsDirectory $params["logs-directory"]
記錄會從每個 Windows 主機複製到本機目錄,$params["logs-directory"]
。 記錄目錄中將有一個以每個 Windows 代理程式主機命名的子目錄。 只有在符合下列需求之後,才能在事件查看器中正確檢查 CCG (Container Credential Guard) .evtx 記錄檔:
- 已安裝容器 Windows 功能。 您可以使用下列命令透過 PowerShell 安裝:
# Needs computer restart
Install-WindowsFeature -Name Containers
- CCGEvents.man 記錄指令清單檔案是透過下列方式註冊:
wevtutil im CCGEvents.man
注意
記錄檔案必須由 Microsoft 提供。
使用 gMSA 設定範例應用程式
除了簡化 AKS 上的 gMSA 設定之外,PowerShell 模組也會提供範例應用程式,讓您用於測試目的。 若要安裝範例應用程式,請執行下列命令:
Get-GMSASampleApplicationYAML `
-SpecName $params["gmsa-spec-name"] `
-AksWindowsNodePoolsNames $params["aks-win-node-pools-names"] | kubectl apply -f -
驗證 AKS 代理程式集區對 Azure Key Vault 的存取
您的 AKS 節點集區必須能夠存取 Azure Key Vault 秘密,才能使用可在 Active Directory 上擷取 gMSA 的帳戶。 請務必正確設定此存取權,讓節點可以與您的 Active Directory 域控制器通訊。 無法存取秘密表示您的應用程式無法進行驗證。 另一方面,您可能想要確保沒有授予不必要的節點集區存取權。
AKS PowerShell 模組上的 gMSA 可讓您驗證哪些節點集區可以存取 Azure Key Vault 上的哪些秘密。
Get-AksAgentPoolsAkvAccess `
-AksResourceGroupName $params["aks-cluster-rg-name"] `
-AksClusterName $params["aks-cluster-name"] `
-VaultResourceGroupNames $params["aks-cluster-rg-name"]
分享意見反應
如需 AKS PowerShell 模組上 gMSA 的意見回饋、問題和建議,請瀏覽 GitHub 上的 Windows 容器儲存庫。