共用方式為


透過 Windows PowerShell 管理 Azure Stack Edge Pro GPU 裝置

適用於:Yes for Pro GPU SKUAzure Stack Edge Pro - GPUYes for Pro 2 SKUAzure Stack Edge Pro 2Yes for Pro R SKUAzure Stack Edge Pro RYes for Mini R SKUAzure Stack Edge Mini R

Azure Stack Edge Pro GPU 解決方案可讓您處理數據,並將其透過網路傳送至 Azure。 本文說明 Azure Stack Edge Pro GPU 裝置的一些設定和管理工作。 您可以使用 Azure 入口網站、本機 Web UI 或 Windows PowerShell 介面來管理您的裝置。

本文著重於如何連線到裝置的PowerShell介面,以及您可以使用這個介面執行的工作。

連線至 Powershell 介面

視用戶端的操作系統而定,遠端連線到裝置的程式會有所不同。

從 Windows 用戶端遠端連線

必要條件

在您開始前,請確定:

  • 您的 Windows 用戶端正在執行 Windows PowerShell 5.0 或更新版本。

  • 您的 Windows 用戶端具有與裝置上安裝之節點憑證對應的簽署鏈結(跟證書)。 如需詳細指示,請參閱 在 Windows 用戶端上安裝憑證。

  • hosts位於 C:\Windows\System32\drivers\etc Windows 用戶端的 檔案具有對應至節點憑證的專案,格式如下:

    <Device IP> <Node serial number>.<DNS domain of the device>

    以下是檔案的 hosts 範例專案:

    10.100.10.10 1HXQG13.wdshcsso.com

詳細步驟

請遵循下列步驟從 Windows 用戶端遠端連線。

  1. 以系統管理員身分執行 Windows PowerShell 會話。

  2. 請確定 Windows 遠端管理服務正在您的用戶端上執行。 在命令提示字元中,輸入:

    winrm quickconfig
    

    如需詳細資訊,請參閱 Windows 遠端管理的安裝和設定。

  3. 將變數指派給檔案中使用的 hosts 連接字串。

    $Name = "<Node serial number>.<DNS domain of the device>"
    

    將和 <DNS domain of the device> 取代<Node serial number>為您裝置的節點序號和 DNS 網域。 您可以從裝置本機 Web UI 中的 [裝置] 頁面,從 [憑證] 頁面和 [DNS 網域] 取得節點序號的值。

  4. 若要將裝置的這個 連接字串 新增至用戶端的受信任主機清單,請輸入下列命令:

    Set-Item WSMan:\localhost\Client\TrustedHosts $Name -Concatenate -Force
    
  5. 在裝置上啟動 Windows PowerShell 工作階段:

    Enter-PSSession -ComputerName $Name -Credential ~\EdgeUser -ConfigurationName Minishell -UseSSL
    

    如果您看到與信任關係相關的錯誤,請檢查上傳至裝置之節點憑證的簽署鏈結是否也會安裝在存取裝置的用戶端上。

  6. 出現提示時提供密碼。 使用用來登入本機 Web UI 的相同密碼。 默認的本機 Web UI 密碼為 Password1。 當您使用遠端 PowerShell 成功連線到裝置時,您會看到下列範例輸出:

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    PS C:\WINDOWS\system32> winrm quickconfig
    WinRM service is already running on this machine.
    PS C:\WINDOWS\system32> $Name = "1HXQG13.wdshcsso.com"
    PS C:\WINDOWS\system32> Set-Item WSMan:\localhost\Client\TrustedHosts $Name -Concatenate -Force
    PS C:\WINDOWS\system32> Enter-PSSession -ComputerName $Name -Credential ~\EdgeUser -ConfigurationName Minishell -UseSSL
    
    WARNING: The Windows PowerShell interface of your device is intended to be used only for the initial network configuration. Please engage Microsoft Support if you need to access this interface to troubleshoot any potential issues you may be experiencing. Changes made through this interface without involving Microsoft Support could result in an unsupported configuration.
    [1HXQG13.wdshcsso.com]: PS>
    

當您使用 -UseSSL 選項時,會透過 HTTPs 透過 PowerShell 遠端處理。 建議您一律使用 HTTPs 透過 PowerShell 從遠端連線。 在信任的網路內,可接受透過 Http 透過 PowerShell 進行遠端處理。 您會先在本機 UI 中透過 HTTP 啟用遠端 PowerShell。 然後,您可以使用上述程式來連線到裝置的 PowerShell 介面,而不需要 -UseSSL 選項。

如果您未使用憑證(我們建議您使用憑證!),您可以使用會話選項略過憑證驗證檢查: -SkipCACheck -SkipCNCheck -SkipRevocationCheck

$sessOptions = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck 
Enter-PSSession -ComputerName $Name -Credential ~\EdgeUser -ConfigurationName Minishell -UseSSL -SessionOption $sessOptions    

以下是略過憑證檢查時的範例輸出:

PS C:\WINDOWS\system32> $Name = "1HXQG13.wdshcsso.com"
PS C:\WINDOWS\system32> $sessOptions = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
PS C:\WINDOWS\system32> $sessOptions

MaximumConnectionRedirectionCount : 5
NoCompression                     : False
NoMachineProfile                  : False
ProxyAccessType                   : None
ProxyAuthentication               : Negotiate
ProxyCredential                   :
SkipCACheck                       : True
SkipCNCheck                       : True
SkipRevocationCheck               : True
OperationTimeout                  : 00:03:00
NoEncryption                      : False
UseUTF16                          : False
IncludePortInSPN                  : False
OutputBufferingMode               : None
MaxConnectionRetryCount           : 0
Culture                           :
UICulture                         :
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize         :
ApplicationArguments              :
OpenTimeout                       : 00:03:00
CancelTimeout                     : 00:01:00
IdleTimeout                       : -00:00:00.0010000

PS C:\WINDOWS\system32> Enter-PSSession -ComputerName $Name -Credential ~\EdgeUser -ConfigurationName Minishell -UseSSL -SessionOption $sessOptions
WARNING: The Windows PowerShell interface of your device is intended to be used only for the initial network configuration. Please
engage Microsoft Support if you need to access this interface to troubleshoot any potential issues you may be experiencing.
Changes made through this interface without involving Microsoft Support could result in an unsupported configuration.
[1HXQG13.wdshcsso.com]: PS>

重要

在目前的版本中,您只能透過 Windows 用戶端連線到裝置的 PowerShell 介面。 此選項 -UseSSL 不適用於Linux用戶端。

建立支援套件

如果您遇到任何裝置問題,您可以從系統記錄建立支援套件。 Microsoft 支援服務 使用此套件來針對問題進行疑難解答。 請遵循下列步驟來建立支援套件:

  1. 連線到裝置的 PowerShell 介面

  2. Get-HcsNodeSupportPackage使用 命令來建立支援套件。 Cmdlet 的使用方式如下:

    Get-HcsNodeSupportPackage [-Path] <string> [-Zip] [-ZipFileName <string>] [-Include {None | RegistryKeys | EtwLogs
            | PeriodicEtwLogs | LogFiles | DumpLog | Platform | FullDumps | MiniDumps | ClusterManagementLog | ClusterLog |
            UpdateLogs | CbsLogs | StorageCmdlets | ClusterCmdlets | ConfigurationCmdlets | KernelDump | RollbackLogs |
            Symbols | NetworkCmdlets | NetworkCmds | Fltmc | ClusterStorageLogs | UTElement | UTFlag | SmbWmiProvider |
            TimeCmds | LocalUILogs | ClusterHealthLogs | BcdeditCommand | BitLockerCommand | DirStats | ComputeRolesLogs |
            ComputeCmdlets | DeviceGuard | Manifests | MeasuredBootLogs | Stats | PeriodicStatLogs | MigrationLogs |
            RollbackSupportPackage | ArchivedLogs | Default}] [-MinimumTimestamp <datetime>] [-MaximumTimestamp <datetime>]
            [-IncludeArchived] [-IncludePeriodicStats] [-Credential <pscredential>]  [<CommonParameters>]
    

    Cmdlet 會從您的裝置收集記錄,並將這些記錄複製到指定的網路或本機共用。

    所使用的參數如下所示:

    • -Path - 指定要複製支援套件的網路或本機路徑。 (必要)
    • -Credential - 指定要存取受保護路徑的認證。
    • -Zip - 指定 以產生 zip 檔案。
    • -Include - 指定要包含在支援套件中的元件。 如果未指定, Default 則會假設為 。
    • -IncludeArchived - 指定 在支援套件中包含封存的記錄。
    • -IncludePeriodicStats - 指定 在支援套件中包含定期統計數據記錄。

檢視裝置資訊

  1. 連線 至 PowerShell 介面

  2. Get-HcsApplianceInfo使用來取得裝置的資訊。

    下列範例顯示此 Cmdlet 的使用方式:

    [10.100.10.10]: PS>Get-HcsApplianceInfo
    
    Id                            : b2044bdb-56fd-4561-a90b-407b2a67bdfc
    FriendlyName                  : DBE-NBSVFQR94S6
    Name                          : DBE-NBSVFQR94S6
    SerialNumber                  : HCS-NBSVFQR94S6
    DeviceId                      : 40d7288d-cd28-481d-a1ea-87ba9e71ca6b
    Model                         : Virtual
    FriendlySoftwareVersion       : Data Box Gateway 1902
    HcsVersion                    : 1.4.771.324
    IsClustered                   : False
    IsVirtual                     : True
    LocalCapacityInMb             : 1964992
    SystemState                   : Initialized
    SystemStatus                  : Normal
    Type                          : DataBoxGateway
    CloudReadRateBytesPerSec      : 0
    CloudWriteRateBytesPerSec     : 0
    IsInitialPasswordSet          : True
    FriendlySoftwareVersionNumber : 1902
    UploadPolicy                  : All
    DataDiskResiliencySettingName : Simple
    ApplianceTypeFriendlyName     : Data Box Gateway
    IsRegistered                  : False
    

    以下是摘要一些重要裝置信息的數據表:

    參數 描述
    FriendlyName 裝置在部署期間透過本機 Web UI 所設定的易記名稱。 預設易記名稱是裝置序號。
    SerialNumber 裝置序號是在處理站指派的唯一號碼。
    模型 Azure Stack Edge 或數據箱閘道裝置的模型。 此模型適用於 Azure Stack Edge 和適用於數據箱閘道的虛擬。
    FriendlySoftwareVersion 對應至裝置軟體版本的易記字串。 針對執行預覽的系統,易記的軟體版本會是 Data Box Edge 1902。
    HcsVersion 在您的裝置上執行的 HCS 軟體版本。 例如,對應至 Data Box Edge 1902 的 HCS 軟體版本是 1.4.771.324。
    LocalCapacityInMb 裝置的本機容量總計,以 Megabits 為單位。
    IsRegistered 這個值表示您的裝置是否已使用服務啟用。

檢視 GPU 驅動程式資訊

如果您的裝置上已設定計算角色,您也可以透過 PowerShell 介面取得 GPU 驅動程式資訊。

  1. 連線 至 PowerShell 介面

  2. Get-HcsGpuNvidiaSmi使用取得裝置的 GPU 驅動程式資訊。

    下列範例顯示此 Cmdlet 的使用方式:

    Get-HcsGpuNvidiaSmi
    

    記下此 Cmdlet 範例輸出中的驅動程序資訊。

    +-----------------------------------------------------------------------------+    
    | NVIDIA-SMI 440.64.00    Driver Version: 440.64.00    CUDA Version: 10.2     |    
    |-------------------------------+----------------------+----------------------+    
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |    
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |    
    |===============================+======================+======================|    
    |   0  Tesla T4            On   | 000029CE:00:00.0 Off |                    0 |    
    | N/A   60C    P0    29W /  70W |   1539MiB / 15109MiB |      0%      Default |    
    +-------------------------------+----------------------+----------------------+    
    |   1  Tesla T4           On  | 0000AD50:00:00.0 Off |                    0 |
    | N/A   58C    P0    29W /  70W |    330MiB / 15109MiB |      0%      Default |
    +-------------------------------+----------------------+----------------------+
    

開啟多行程服務 (MPS)

Nvidia GPU 上的多進程服務 (MPS) 提供一種機制,讓多個作業可以共用 GPU,其中每個作業都會配置 GPU 資源的一些百分比。 MPS 是 Azure Stack Edge Pro GPU 裝置上的預覽功能。 若要在您的裝置上啟用 MPS,請遵循下列步驟:

  1. 在您開始前,請確定:

    1. 您已在 Azure 中使用 Azure Stack Edge 資源設定並 啟用 Azure Stack Edge Pro 裝置
    2. 您已在 Azure 入口網站 中設定此裝置上的計算。
  2. 連線 至 PowerShell 介面

  3. 使用下列命令在您的裝置上啟用 MPS。

    Start-HcsGpuMPS
    

注意

當裝置軟體和 Kubernetes 叢集更新時,不會保留適用於工作負載的 MPS 設定。 您必須再次啟用 MPS。

重設裝置

若要重設裝置,您必須安全地抹除數據磁碟和裝置開機磁碟上的所有數據。

Reset-HcsAppliance使用 Cmdlet 來抹除數據磁碟和開機磁碟,或只抹除數據磁碟。 SecureWipeBootDiskSecureWipeDataDisks 參數可讓您分別抹除開機磁碟和數據磁碟。

交換 SecureWipeBootDisk 器會抹除開機磁碟,並使裝置無法使用。 只有當裝置需要返回 Microsoft 時,才應該使用它。 如需詳細資訊,請參閱 將裝置傳回 Microsoft

如果您在本機 Web UI 中使用裝置重設,則只會安全地抹除數據磁碟,但開機磁碟會保持不變。 開機磁碟包含裝置組態。

  1. 連線 至 PowerShell 介面

  2. 在命令提示字元中,輸入:

    Reset-HcsAppliance -SecureWipeBootDisk -SecureWipeDataDisks

    下列範例示範如何使用這個 Cmdlet:

    [10.128.24.33]: PS>Reset-HcsAppliance -SecureWipeBootDisk -SecureWipeDataDisks
    
    Confirm
    Are you sure you want to perform this action?
    Performing the operation "Reset-HcsAppliance" on target "ShouldProcess appliance".
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): N
    

取得計算記錄

如果您的裝置上已設定計算角色,您也可以透過PowerShell介面取得計算記錄。

  1. 連線 至 PowerShell 介面

  2. Get-AzureDataBoxEdgeComputeRoleLogs使用取得裝置的計算記錄。

    下列範例顯示此 Cmdlet 的使用方式:

    Get-AzureDataBoxEdgeComputeRoleLogs -Path "\\hcsfs\logs\myacct" -Credential "username" -FullLogCollection    
    

    以下是 Cmdlet 所使用的參數描述:

    • Path:提供您要在其中建立計算記錄封裝之共用的網路路徑。
    • Credential:提供網路共用的用戶名稱。 當您執行此 Cmdlet 時,您必須提供共享密碼。
    • FullLogCollection:此參數可確保記錄套件將包含所有計算記錄。 根據預設,記錄套件只包含記錄的子集。

變更 Kubernetes 工作負載配置檔

在您形成並設定叢集並建立新的虛擬交換器之後,您可以新增或刪除與虛擬交換器相關聯的虛擬網路。 如需詳細步驟,請參閱 設定虛擬交換器

建立虛擬交換器之後,您可以啟用 Kubernetes 計算流量的交換器,以指定 Kubernetes 工作負載配置檔。 若要使用本機 UI 執行此動作,請使用設定計算 IPS 中的步驟。 若要使用 PowerShell 執行此動作,請使用下列步驟:

  1. 連線 至 PowerShell 介面

  2. Get-HcsApplianceInfo使用 Cmdlet 取得裝置的目前KubernetesPlatformKubernetesWorkloadProfile設定。

  3. Get-HcsKubernetesWorkloadProfiles使用 Cmdlet 來識別 Azure Stack Edge 裝置上可用的配置檔。

    [Device-IP]: PS>Get-HcsKubernetesWorkloadProfiles 
    Type  Description    
    ----  -----------   
    AP5GC an Azure Private MEC solution   
    SAP   a SAP Digital Manufacturing for Edge Computing or another Microsoft partner solution   
    NONE  other workloads
    [Device-IP]: PS>
    
  4. Set-HcsKubernetesWorkloadProfile使用 Cmdlet 來設定 AP5GC 的工作負載配置檔,這是 Azure 私人 MEC 解決方案。

    下列範例顯示此 Cmdlet 的使用方式:

    Set-HcsKubernetesWorkloadProfile -Type "AP5GC"
    

    以下是此 Cmdlet 的範例輸出:

    [10.100.10.10]: PS>KubernetesPlatform : AKS
    [10.100.10.10]: PS>KubernetesWorkloadProfile : AP5GC
    [10.100.10.10]: PS>
    

變更 Kubernetes Pod 和服務子網路

如果您在環境中執行 其他工作負載 選項,根據預設,Azure Stack Edge 裝置上的 Kubernetes 會分別針對 Pod 和服務使用子網 172.27.0.0/16 和 172.28.0.0/16。 如果這些子網已在網路中使用中,您可以執行 Set-HcsKubeClusterNetworkInfo Cmdlet 來變更這些子網。

您想要先執行此設定,再從 Azure 入口網站 設定計算,因為 Kubernetes 叢集是在此步驟中建立。

  1. 連線 裝置的PowerShell介面。

  2. 從裝置的PowerShell介面執行:

    Set-HcsKubeClusterNetworkInfo -PodSubnet <subnet details> -ServiceSubnet <subnet details>

    將 <子網詳細數據> 取代為您想要使用的子網範圍。

  3. 執行此命令之後,您可以使用 Get-HcsKubeClusterNetworkInfo 命令來確認 Pod 和服務子網已變更。

以下是此命令的範例輸出。

[10.100.10.10]: PS>Set-HcsKubeClusterNetworkInfo -PodSubnet 10.96.0.1/16 -ServiceSubnet 10.97.0.1/16
[10.100.10.10]: PS>Get-HcsKubeClusterNetworkInfo

Id                                   PodSubnet    ServiceSubnet
--                                   ---------    -------------
6dbf23c3-f146-4d57-bdfc-76cad714cfd1 10.96.0.1/16 10.97.0.1/16
[10.100.10.10]: PS>

開始之前,您必須具備:

  • 已設定計算網路。 請參閱 教學課程:使用 GPU 設定 Azure Stack Edge Pro 的網路。
  • 在您的裝置上設定的計算角色。

在已設定計算角色的 Azure Stack Edge Pro GPU 裝置上,您可以使用兩組不同的命令對裝置進行疑難解答或監視。

  • 使用 iotedge 命令。 這些命令適用於您裝置的基本作業。
  • 使用 kubectl 命令。 這些命令適用於您裝置的大量作業集。

若要執行上述任一組命令,您必須 連線 至 PowerShell 介面

使用 iotedge 命令

若要查看可用的命令清單, 請連線到 PowerShell 介面 並使用 函 iotedge 式。

[10.100.10.10]: PS>iotedge -?                                                                                                                           
Usage: iotedge COMMAND

Commands:
   list
   logs
   restart

[10.100.10.10]: PS>

下表簡短描述 可用的 iotedge命令:

命令 描述
list 列出模組
logs 擷取模組的記錄
restart 停止並重新啟動模組

列出所有IoT Edge模組

若要列出裝置上執行的所有模組,請使用 iotedge list 命令。

以下是此命令的範例輸出。 此命令會列出所有模組、相關聯的組態,以及與模組相關聯的外部IP。 例如,您可以在 存取 Webserver 應用程式 https://10.128.44.244

[10.100.10.10]: PS>iotedge list

NAME                   STATUS  DESCRIPTION CONFIG                                             EXTERNAL-IP
----                   ------  ----------- ------                                             -----
gettingstartedwithgpus Running Up 10 days  mcr.microsoft.com/intelligentedge/solutions:latest
iotedged               Running Up 10 days  azureiotedge/azureiotedge-iotedged:0.1.0-beta10    <none>
edgehub                Running Up 10 days  mcr.microsoft.com/azureiotedge-hub:1.0             10.128.44.243
edgeagent              Running Up 10 days  azureiotedge/azureiotedge-agent:0.1.0-beta10
webserverapp           Running Up 10 days  nginx:stable                                       10.128.44.244

[10.100.10.10]: PS>

重新啟動模組

您可以使用 list 命令來列出裝置上執行的所有模組。 然後,識別您要重新啟動的模組名稱,並將它與 命令搭配 restart 使用。

以下是如何重新啟動模組的範例輸出。 根據模組執行時間長度的描述,您可以看到 cuda-sample1 該模組已重新啟動。

[10.100.10.10]: PS>iotedge list

NAME         STATUS  DESCRIPTION CONFIG                                          EXTERNAL-IP PORT(S)
----         ------  ----------- ------                                          ----------- -------
edgehub      Running Up 5 days   mcr.microsoft.com/azureiotedge-hub:1.0          10.57.48.62 443:31457/TCP,5671:308
                                                                                             81/TCP,8883:31753/TCP
iotedged     Running Up 7 days   azureiotedge/azureiotedge-iotedged:0.1.0-beta13 <none>      35000/TCP,35001/TCP
cuda-sample2 Running Up 1 days   nvidia/samples:nbody
edgeagent    Running Up 7 days   azureiotedge/azureiotedge-agent:0.1.0-beta13
cuda-sample1 Running Up 1 days   nvidia/samples:nbody

[10.100.10.10]: PS>iotedge restart cuda-sample1
[10.100.10.10]: PS>iotedge list

NAME         STATUS  DESCRIPTION  CONFIG                                          EXTERNAL-IP PORT(S)
----         ------  -----------  ------                                          ----------- -------
edgehub      Running Up 5 days    mcr.microsoft.com/azureiotedge-hub:1.0          10.57.48.62 443:31457/TCP,5671:30
                                                                                              881/TCP,8883:31753/TC
                                                                                              P
iotedged     Running Up 7 days    azureiotedge/azureiotedge-iotedged:0.1.0-beta13 <none>      35000/TCP,35001/TCP
cuda-sample2 Running Up 1 days    nvidia/samples:nbody
edgeagent    Running Up 7 days    azureiotedge/azureiotedge-agent:0.1.0-beta13
cuda-sample1 Running Up 4 minutes nvidia/samples:nbody

[10.100.10.10]: PS>

取得模組記錄

logs使用 命令來取得裝置上執行之任何 IoT Edge 模組的記錄。

如果在建立容器映像或擷取映像時發生錯誤,請執行 logs edgeagentedgeagent 是負責布建其他容器的IoT Edge運行時間容器。 由於 logs edgeagent 會傾印所有記錄,因此查看最近錯誤的好方法是使用選項 --tail 0』。

以下是範例輸出。

[10.100.10.10]: PS>iotedge logs cuda-sample2 --tail 10
[10.100.10.10]: PS>iotedge logs edgeagent --tail 10
<6> 2021-02-25 00:52:54.828 +00:00 [INF] - Executing command: "Report EdgeDeployment status: [Success]"
<6> 2021-02-25 00:52:54.829 +00:00 [INF] - Plan execution ended for deployment 11
<6> 2021-02-25 00:53:00.191 +00:00 [INF] - Plan execution started for deployment 11
<6> 2021-02-25 00:53:00.191 +00:00 [INF] - Executing command: "Create an EdgeDeployment with modules: [cuda-sample2, edgeAgent, edgeHub, cuda-sample1]"
<6> 2021-02-25 00:53:00.212 +00:00 [INF] - Executing command: "Report EdgeDeployment status: [Success]"
<6> 2021-02-25 00:53:00.212 +00:00 [INF] - Plan execution ended for deployment 11
<6> 2021-02-25 00:53:05.319 +00:00 [INF] - Plan execution started for deployment 11
<6> 2021-02-25 00:53:05.319 +00:00 [INF] - Executing command: "Create an EdgeDeployment with modules: [cuda-sample2, edgeAgent, edgeHub, cuda-sample1]"
<6> 2021-02-25 00:53:05.412 +00:00 [INF] - Executing command: "Report EdgeDeployment status: [Success]"
<6> 2021-02-25 00:53:05.412 +00:00 [INF] - Plan execution ended for deployment 11
[10.100.10.10]: PS>

注意

Azure Stack Edge 上的 IoT Edge 不支援 GetModuleLogs 或 UploadModuleLogs 等直接方法。

使用 kubectl 命令

在已設定計算角色的 Azure Stack Edge Pro GPU 裝置上 kubectl ,所有命令都可供監視或疑難解答模組。 若要查看可用的命令清單,請從命令視窗執行 kubectl --help

C:\Users\myuser>kubectl --help

kubectl controls the Kubernetes cluster manager.

Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/

Basic Commands (Beginner):
    create         Create a resource from a file or from stdin.
    expose         Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
    run            Run a particular image on the cluster
    set            Set specific features on objects
    run-container  Run a particular image on the cluster. This command is deprecated, use "run" instead
==============CUT=============CUT============CUT========================

Usage:
    kubectl [flags] [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).

C:\Users\myuser>

如需命令的完整清單 kubectl ,請移至 kubectl 速查表

取得 Kubernetes 叢集外部公開的服務或模組 IP

若要取得 Kubernetes 外部公開的負載平衡服務或模組的 IP,請執行下列命令:

kubectl get svc -n iotedge

以下是 Kubernetes 叢集外部公開之所有服務或模組的範例輸出。

[10.100.10.10]: PS>kubectl get svc -n iotedge
NAME           TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)                                       AGE
edgehub        LoadBalancer   10.103.52.225   10.128.44.243   443:31987/TCP,5671:32336/TCP,8883:30618/TCP   34h
iotedged       ClusterIP      10.107.236.20   <none>          35000/TCP,35001/TCP                           3d8h
webserverapp   LoadBalancer   10.105.186.35   10.128.44.244   8080:30976/TCP                                16h

[10.100.10.10]: PS>

[外部 IP] 資料行中的 IP 位址會對應至服務或模組的外部端點。 您也可以 在 Kubernetes 儀錶板中取得外部 IP。

檢查是否已成功部署模組

計算模組是已實作商業規則的容器。 Kubernetes Pod 可以有多個容器正在執行。

若要檢查計算模組是否已成功部署,請連線到裝置的PowerShell介面。 執行 命令, get pods 並檢查容器是否正在執行中(對應至計算模組)。

若要取得在特定命名空間中執行的所有 Pod 清單,請執行下列命令:

get pods -n <namespace>

若要檢查透過IoT Edge部署的模組,請執行下列命令:

get pods -n iotedge

以下是命名空間中執行之所有 Pod 的 iotedge 範例輸出。

[10.100.10.10]: PS>kubectl get pods -n iotedge
NAME                        READY   STATUS    RESTARTS   AGE
edgeagent-cf6d4ffd4-q5l2k   2/2     Running   0          20h
edgehub-8c9dc8788-2mvwv     2/2     Running   0          56m
filemove-66c49984b7-h8lxc   2/2     Running   0          56m
iotedged-675d7f4b5f-9nml4   1/1     Running   0          20h

[10.100.10.10]: PS>

狀態狀態表示命名空間中的所有Pod正在執行,而Ready表示Pod中部署的容器數目。 在上述範例中,所有 Pod 都會執行,且部署在每個 Pod 中的所有模組都會執行。

若要檢查透過 Azure Arc 部署的模組,請執行下列命令:

get pods -n azure-arc

或者,您可以 連線 Kubernetes 儀錶板來查看 IoT Edge 或 Azure Arc 部署

如需指定命名空間之特定 Pod 的更詳細資訊輸出,您可以執行下列命令:

kubectl describe pod <pod name> -n <namespace>

範例輸出如下所示。

[10.100.10.10]: PS>kubectl describe pod filemove-66c49984b7 -n iotedge
Name:           filemove-66c49984b7-h8lxc
Namespace:      iotedge
Priority:       0
Node:           k8s-1hwf613cl-1hwf613/10.139.218.12
Start Time:     Thu, 14 May 2020 12:46:28 -0700
Labels:         net.azure-devices.edge.deviceid=myasegpu-edge
                net.azure-devices.edge.hub=myasegpu2iothub.azure-devices.net
                net.azure-devices.edge.module=filemove
                pod-template-hash=66c49984b7
Annotations:    net.azure-devices.edge.original-moduleid: filemove
Status:         Running
IP:             172.17.75.81
IPs:            <none>
Controlled By:  ReplicaSet/filemove-66c49984b7
Containers:
    proxy:
    Container ID:   docker://fd7975ca78209a633a1f314631042a0892a833b7e942db2e7708b41f03e8daaf
    Image:          azureiotedge/azureiotedge-proxy:0.1.0-beta8
    Image ID:       docker://sha256:5efbf6238f13d24bab9a2b499e5e05bc0c33ab1587d6cf6f289cdbe7aa667563
    Port:           <none>
    Host Port:      <none>
    State:          Running
        Started:      Thu, 14 May 2020 12:46:30 -0700
    Ready:          True
    Restart Count:  0
    Environment:
        PROXY_LOG:  Debug
=============CUT===============================CUT===========================
Volumes:
    config-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      iotedged-proxy-config
    Optional:  false
    trust-bundle-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      iotedged-proxy-trust-bundle
    Optional:  false
    myasesmb1local:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  myasesmb1local
    ReadOnly:   false
    myasesmb1:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  myasesmb1
    ReadOnly:   false
    filemove-token-pzvw8:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  filemove-token-pzvw8
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                    node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>


[10.100.10.10]: PS>

取得容器記錄

若要取得模組的記錄,請從裝置的PowerShell介面執行下列命令:

kubectl logs <pod_name> -n <namespace> --all-containers

因為 all-containers 旗標會傾印所有容器的所有記錄,因此查看最近錯誤的好方法是使用 選項 --tail 10

以下是範例輸出。

[10.100.10.10]: PS>kubectl logs filemove-66c49984b7-h8lxc -n iotedge --all-containers --tail 10
DEBUG 2020-05-14T20:40:42Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:40:44Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:40:44Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:40:44Z: loop process - 1 events, 0.000s
DEBUG 2020-05-14T20:40:44Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:42:12Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:42:14Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:42:14Z: loop process - 0 events, 0.000s
DEBUG 2020-05-14T20:42:14Z: loop process - 1 events, 0.000s
DEBUG 2020-05-14T20:42:14Z: loop process - 0 events, 0.000s
05/14/2020 19:46:44: Info: Opening module client connection.
05/14/2020 19:46:45: Info: Open done.
05/14/2020 19:46:45: Info: Initializing with input: /home/input, output: /home/output, protocol: Amqp.
05/14/2020 19:46:45: Info: IoT Hub module client initialized.

[10.100.10.10]: PS>

變更 Kubernetes 背景工作節點的記憶體、處理器限制

若要變更 Kubernetes 背景工作節點的記憶體或處理器限制,請執行下列步驟:

  1. 連線 至裝置的PowerShell介面。

  2. 若要取得背景工作節點和角色選項的目前資源,請執行下列命令:

    Get-AzureDataBoxEdgeRole

    以下是範例輸出。 請注意 區段下 ResourcesCompute 的值NameMemoryInBytesProcessorCount 表示 Kubernetes 背景工作節點目前指派的值記憶體和處理器計數。

    [10.100.10.10]: PS>Get-AzureDataBoxEdgeRole
    ImageDetail                : Name:mcr.microsoft.com/azureiotedge-agent
                                 Tag:1.0
                                 PlatformType:Linux
    EdgeDeviceConnectionString :
    IotDeviceConnectionString  :
    HubHostName                : ase-srp-007.azure-devices.net
    IotDeviceId                : srp-007-storagegateway
    EdgeDeviceId               : srp-007-edge
    Version                    :
    Id                         : 6ebeff9f-84c5-49a7-890c-f5e05520a506
    Name                       : IotRole
    Type                       : IOT
    Resources                  : Compute:
                                 MemoryInBytes:34359738368
                                 ProcessorCount:12
                                 VMProfile:
    
                                 Storage:
                                 EndpointMap:
                                 EndpointId:c0721210-23c2-4d16-bca6-c80e171a0781
                                 TargetPath:mysmbedgecloudshare1
                                 Name:mysmbedgecloudshare1
                                 Protocol:SMB
    
                                 EndpointId:6557c3b6-d3c5-4f94-aaa0-6b7313ab5c74
                                 TargetPath:mysmbedgelocalshare
                                 Name:mysmbedgelocalshare
                                 Protocol:SMB
                                 RootFileSystemStorageSizeInBytes:0
    
    HostPlatform               : KubernetesCluster
    State                      : Created
    PlatformType               : Linux
    HostPlatformInstanceId     : 994632cb-853e-41c5-a9cd-05b36ddbb190
    IsHostPlatformOwner        : True
    IsCreated                  : True    
    [10.100.10.10]: PS>
    
  3. 若要變更背景工作節點的記憶體和處理器值,請執行下列命令:

    Set-AzureDataBoxEdgeRoleCompute -Name <Name value from the output of Get-AzureDataBoxEdgeRole> -Memory <Value in Bytes> -ProcessorCount <No. of cores>
    

    以下是範例輸出。

    [10.100.10.10]: PS>Set-AzureDataBoxEdgeRoleCompute -Name IotRole -MemoryInBytes 32GB -ProcessorCount 16
    
    ImageDetail                : Name:mcr.microsoft.com/azureiotedge-agent
                                 Tag:1.0
                                 PlatformType:Linux
    
    EdgeDeviceConnectionString :
    IotDeviceConnectionString  :
    HubHostName                : ase-srp-007.azure-devices.net
    IotDeviceId                : srp-007-storagegateway
    EdgeDeviceId               : srp-007-edge
    Version                    :
    Id                         : 6ebeff9f-84c5-49a7-890c-f5e05520a506
    Name                       : IotRole
    Type                       : IOT
    Resources                  : Compute:
                                 MemoryInBytes:34359738368
                                 ProcessorCount:16
                                 VMProfile:
    
                                 Storage:
                                 EndpointMap:
                                 EndpointId:c0721210-23c2-4d16-bca6-c80e171a0781
                                 TargetPath:mysmbedgecloudshare1
                                 Name:mysmbedgecloudshare1
                                 Protocol:SMB
    
                                 EndpointId:6557c3b6-d3c5-4f94-aaa0-6b7313ab5c74
                                 TargetPath:mysmbedgelocalshare
                                 Name:mysmbedgelocalshare
                                 Protocol:SMB
    
                                 RootFileSystemStorageSizeInBytes:0
    
    HostPlatform               : KubernetesCluster
    State                      : Created
    PlatformType               : Linux
    HostPlatformInstanceId     : 994632cb-853e-41c5-a9cd-05b36ddbb190
    IsHostPlatformOwner        : True
    IsCreated                  : True
    
    [10.100.10.10]: PS>    
    

變更記憶體和處理器使用量時,請遵循這些指導方針。

  • 默認記憶體是裝置規格的 25%。
  • 默認處理器計數是裝置規格的 30%。
  • 變更記憶體和處理器計數的值時,建議您將 15% 到 60% 的裝置記憶體和處理器計數之間的值變更。
  • 我們建議 60% 的上限,讓系統元件有足夠的資源。

連線 至 BMC

注意

基礎板管理控制器 (BMC) 不適用於 Azure Stack Edge Pro 2 和 Azure Stack Edge Mini R。本節所述的 Cmdlet 僅適用於 Azure Stack Edge Pro GPU 和 Azure Stack Edge Pro R。

BMC 可用來遠端監視和管理您的裝置。 本節描述可用來管理 BMC 設定的 Cmdlet。 在執行上述任何 Cmdlet 之前,連線 裝置的 PowerShell 介面。

  • Get-HcsNetBmcInterface:使用此 Cmdlet 取得 BMC 的網路組態屬性,例如 、IPv4AddressIPv4GatewayIPv4SubnetMaskDhcpEnabled

    以下是範例輸出:

    [10.100.10.10]: PS>Get-HcsNetBmcInterface
    IPv4Address   IPv4Gateway IPv4SubnetMask DhcpEnabled
    -----------   ----------- -------------- -----------
    10.128.53.186 10.128.52.1 255.255.252.0        False
    [10.100.10.10]: PS>
    
  • Set-HcsNetBmcInterface:您可以使用下列兩種方式使用此 Cmdlet。

    • 使用 Cmdlet 來啟用或停用 BMC 的 DHCP 組態,方法是使用參數的適當值 UseDhcp

      Set-HcsNetBmcInterface -UseDhcp $true
      

      以下是範例輸出:

      [10.100.10.10]: PS>Set-HcsNetBmcInterface -UseDhcp $true
      [10.100.10.10]: PS>Get-HcsNetBmcInterface
      IPv4Address IPv4Gateway IPv4SubnetMask DhcpEnabled
      ----------- ----------- -------------- -----------
      10.128.54.8 10.128.52.1 255.255.252.0         True
      [10.100.10.10]: PS>
      
    • 使用此 Cmdlet 來設定 BMC 的靜態組態。 您可以指定、 IPv4GatewayIPv4SubnetMask的值IPv4Address

      Set-HcsNetBmcInterface -IPv4Address "<IPv4 address of the device>" -IPv4Gateway "<IPv4 address of the gateway>" -IPv4SubnetMask "<IPv4 address for the subnet mask>"
      

      以下是範例輸出:

      [10.100.10.10]: PS>Set-HcsNetBmcInterface -IPv4Address 10.128.53.186 -IPv4Gateway 10.128.52.1 -IPv4SubnetMask 255.255.252.0
      [10.100.10.10]: PS>Get-HcsNetBmcInterface
      IPv4Address   IPv4Gateway IPv4SubnetMask DhcpEnabled
      -----------   ----------- -------------- -----------
      10.128.53.186 10.128.52.1 255.255.252.0        False
      [10.100.10.10]: PS>
      
  • Set-HcsBmcPassword:使用此 Cmdlet 修改 的 EdgeUserBMC 密碼。 用戶名稱 - EdgeUser會區分大小寫。

    以下是範例輸出:

    [10.100.10.10]: PS> Set-HcsBmcPassword -NewPassword "Password1"
    [10.100.10.10]: PS>
    

結束遠程會話

若要結束遠端 PowerShell 工作階段,請關閉 PowerShell 視窗。

下一步