你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

快速入门:安装通过 Azure Arc 启用的 Edge RAG 预览版

在本快速入门中,你将在 Azure Kubernetes 服务(AKS)上部署 Edge RAG,而无需本地硬件(如 Azure 本地)。 本快速入门旨在帮助你开始使用 Edge RAG 进行评估或开发。 若要为生产环境部署 Edge RAG,请参阅 部署概述

重要

由 Azure Arc 启用的 Edge RAG 预览版目前为预览版。 有关适用于 Beta 版、预览版或尚未正式发布的 Azure 功能的法律条款,请参阅 适用于 Microsoft azure 预览版的补充使用条款

先决条件

在开始之前,请确保具备:

打开 Azure Cloud Shell 或 Azure CLI

打开 Azure Cloud Shell 或本地 Azure CLI 以运行本文中的命令。 在 Azure Cloud Shell 中,可能需要选择“ 切换到 PowerShell”。

  1. 登录到 Azure 以开始:

    az login
    
  2. 如果有多个订阅,请运行以下命令以获取订阅列表,然后将会话的上下文设置为相应的订阅名称:

    az account list --output table
    

    将占位符“订阅名称”替换为你的订阅,并运行以下命令:

    $sub = "<subscription name>" 
    az account set --subscription  $sub
    

创建资源组

创建资源组以包含 AKS 群集、节点池和 Edge RAG 资源。

$rg = "edge-rag-aks-rg" 
$location = "eastus2"
az group create `
     --name $rg `
     --location $location

创建和配置 AKS 群集

在本部分中,将创建 AKS 群集并将其配置为 Edge RAG 部署。 这些步骤包括设置群集、将其连接到 Azure Arc 以及准备必要的扩展和 GPU 支持。

  1. 创建 AKS 群集:

    $k8scluster = "edge-rag-aks"  
    az aks create `
       --resource-group $rg `
       --name $k8scluster `
       --node-count 2 `
       --generate-ssh-keys
    
  2. 根据需要设置以下值的其余部分,然后运行该命令。 如果在 AKS 群集的不同租户中为 Edge RAG 创建了应用程序注册,可在 Azure 门户中的 $entraAppId 应用注册页上使用$entraTenantId目录(租户)ID 设置值

    
    # Set Edge RAG extension values
    $modelName = "microsoft/Phi-3.5"    
    $gpu_enabled = "true" # set to false if no GPU nodes 
    $localextname = "edgeragdemo"  
    $autoUpgrade = "false" 
    $extension = "microsoft.arc.rag" # do not change    
    $n = "arc-rag" # do not change
    
    # Set Entra ID app registration values
    $domainName = "arcrag.contoso.com" # Edit to match the domain used in your registration  
    $entraAppId = $(az ad app list --display-name "EdgeRAG" --query "[].appId" --output tsv)  # Display name is the application name in your registration   
    $entraTenantId = $(az account show --query tenantId --output tsv) # Directory or tenant ID     
    
    

    如果在设置$entraAppId或使用$entraTenantId查询时收到警告,请使用 Azure 门户中 EdgeRAG 应用注册页上的应用程序(客户端)ID目录(租户)ID 设置值。

  3. 连接到 Azure 和 AKS:

    az login `
       --scope https://management.core.windows.net//.default `
       --tenant $entraTenantId    
    az aks get-credentials `
       --resource-group $rg `
       --name $k8scluster `
       --overwrite-existing 
    

    按照命令行中的提示登录并选择订阅。

  4. 在群集上安装 NVIDIA GPU 操作员:

    helm repo add nvidia https://helm.ngc.nvidia.com/nvidia 
    helm repo update   
    helm install --wait --generate-name -n gpu-operator --create-namespace nvidia/gpu-operator --version=v24.9.2 
    
  5. 通过运行以下命令注册Microsoft.Kubernetes提供程序:

    az provider register -n Microsoft.Kubernetes
    
  6. 将 AKS 群集连接到 Azure Arc:

    az connectedk8s connect `
       --resource-group $rg ` 
       --location $location ` 
       --name $k8scluster  
    

    如果系统提示,请选择 y 以安装扩展“connectedk8s”。

  7. 安装所需的证书和信任管理器:

    
     kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.3/cert-manager.yaml --wait  
     helm repo add jetstack https://charts.jetstack.io --force-update  
     start-sleep -Seconds 20 
     helm upgrade trust-manager jetstack/trust-manager --install --namespace cert-manager --wait 
    

创建节点池

将专用 GPU 和 CPU 节点池添加到 AKS 群集以支持 Edge RAG。

如果在尝试创建节点池时收到错误消息,则可能需要请求增加 Azure 订阅的配额,尝试其他虚拟机大小,或者在其他 Azure 区域中创建 Azure Kubernetes 群集和节点池。 有关详细信息,请参阅 Azure Kubernetes 服务(AKS)中资源、SKU 和区域的限制

  1. 运行以下命令,创建包含节点的 GPU 节点池:

    az aks nodepool add ` 
        --resource-group $rg ` 
        --cluster-name $k8scluster ` 
        --name "gpunodepool" ` 
        --node-count 4 ` 
        --node-vm-size "Standard_NC24ads_A100_v4" `
        --enable-cluster-autoscaler `
        --min-count 4 ` 
        --max-count 4 ` 
        --mode User 
    
  2. 运行以下命令,创建包含节点的 CPU 节点池:

    az aks nodepool add ` 
        --resource-group $rg ` 
        --cluster-name $k8scluster ` 
        --name "cpunodepool" ` 
        --node-count 4 ` 
        --node-vm-size "Standard_D8s_v3" ` 
        --enable-cluster-autoscaler ` 
        --min-count 4 ` 
        --max-count 4 ` 
        --mode User
    

在 AKS 上部署 Edge RAG

完成以下步骤,将 Edge RAG 扩展部署到 AKS 群集。

  1. 通过运行以下命令部署 Edge RAG 扩展:

    az k8s-extension create `    
        --cluster-type connectedClusters `   
        --cluster-name $k8scluster `    
        --resource-group $rg `    
        --name $localextname `   
        --extension-type $extension `    
        --debug --release-train preview ` 
        --auto-upgrade $autoUpgrade ` 
        --configuration-settings isManagedIdentityRequired=true ` 
        --configuration-settings gpu_enabled=$gpu_enabled ` 
        --configuration-settings AgentOperationTimeoutInMinutes=60 ` 
        --configuration-settings model=$modelName ` 
        --configuration-settings auth.tenantId=$entraTenantId ` 
        --configuration-settings auth.clientId=$entraAppId ` 
        --configuration-settings ingress.domainname=$domainName ` 
        --configuration-settings ingress-nginx.controller.service.annotations.service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path=/healthz 
    

    等待几分钟才能完成部署。

  2. 运行以下命令获取负载均衡器 VIP:

    kubectl get service ingress-nginx-controller -n arc-rag -o yaml 
    

    查找:

    status:    
      loadBalancer:   
        ingress:    
         - ip: <load_balancer_ip>    
       ipMode: VIP 
    

连接到开发人员门户

更新本地计算机上的主机文件,以连接到 Edge RAG 的开发人员门户。

  1. 在本地计算机上,在管理员模式下打开记事本。

  2. 转到 文件>打开>C:/windows/System32/drivers/etc>hosts。 如果看不到“hosts”文件,请将扩展类型设置为 “所有文件”。

  3. 在文件末尾添加以下行,您需要将 load_balancer_ip 替换为负载均衡器 IP,并编辑域以匹配应用注册:

    <load_balancer_ip> arcrag.contoso.com

    例如:

    # Edge RAG developer portal
    172.16.0.0 arcrag.contoso.com
    
  4. 保存文件。

  5. 使用你添加到本地“hosts”文件中的域 URL,前往 Edge RAG 的开发者门户。 例如: https://arcrag.contoso.com

  6. 选择“开始”。 然后,按照本文末尾的后续步骤添加数据源并设置数据查询。

(可选)清理资源

如果已尝试 Edge RAG,请运行以下命令删除本快速入门中创建的资源:

az group delete `
   --name $rg `
   --yes `
   --no-wait

后续步骤