共用方式為


部署 Apache Superset™

重要

此功能目前為預覽功能。 適用於 Microsoft Azure 預覽版的補充使用規定包含適用於 Beta 版、預覽版或尚未發行至正式運作之 Azure 功能的更合法條款。 如需此特定預覽的相關信息,請參閱 AKS 預覽資訊的 Azure HDInsight。 如需問題或功能建議,請在 AskHDInsight提交要求,並提供詳細數據,並遵循我們在 Azure HDInsight 社群取得更多更新。

視覺效果對於有效地探索、呈現及共用數據至關重要。 Apache Superset 可讓您在彈性的 Web UI 中,透過您的資料執行查詢、可視化及建置儀錶板。

本文說明如何在 Azure 中部署 Apache Superset UI 實例,並在 AKS 上使用 HDInsight 將其連線到 Trino 叢集,以查詢數據並建立儀錶板。

本文所涵蓋步驟的摘要:

  1. 必要條件
  2. 建立 Apache Superset 的 Kubernetes 叢集。
  3. 部署 Apache Superset

必要條件

如果使用 Windows,請使用 WSL2 上的 Ubuntu,在 Windows 內的 bash 殼層 Linux 環境中執行這些指示。 否則,您必須修改命令以在 Windows 中運作。

建立 Trino 叢集並指派受控識別

  1. 如果您尚未這麼做,請在 AKS 上建立具有 HDInsight 的 Trino 叢集。

  2. 若要讓 Apache Superset 呼叫 Trino,它必須具有受控識別 (MSI)。 建立或挑選現有的 使用者指派受控識別

  3. 修改您的 Trino 叢集組態,以允許在步驟 2 中建立的受控識別執行查詢。 瞭解如何管理存取權。

安裝本機工具

  1. 設定 Azure CLI。

    a. 安裝 Azure CLI

    b. 登入 Azure CLI: az login

    c. 安裝 Azure CLI 預覽延伸模組。

    # Install the aks-preview extension
    az extension add --name aks-preview
    
    # Update the extension to make sure you've the latest version installed
    az extension update --name aks-preview
    
  2. 安裝 Kubernetes

  3. 安裝 Helm

建立 Apache Superset 的 kubernetes 叢集

此步驟會建立 Azure Kubernetes Service (AKS) 叢集,您可以在其中安裝 Apache Superset。 您必須系結與叢集相關聯的受控識別,才能讓 Superset 使用該身分識別向 Trino 叢集進行驗證。

  1. 在Bash中為超集安裝建立下列變數。

    # ----- Parameters ------
    
    # The subscription ID where you want to install Superset
    SUBSCRIPTION=
    # Superset cluster name (visible only to you)
    CLUSTER_NAME=trinosuperset 
    # Resource group containing the Azure Kubernetes service
    RESOURCE_GROUP_NAME=trinosuperset 
    # The region to deploy Superset (ideally same region as Trino): to list regions: az account list-locations REGION=westus3 
    # The resource path of your managed identity. To get this resource path:
    #   1. Go to the Azure Portal and find your user assigned managed identity
    #   2. Select JSON View on the top right
    #   3. Copy the Resource ID value.
    MANAGED_IDENTITY_RESOURCE=
    
  2. 選取您要安裝 Superset 的訂用帳戶。

    az account set --subscription $SUBSCRIPTION
    
  3. 在您的目前訂用帳戶上啟用Pod身分識別功能。

    az feature register --name EnablePodIdentityPreview --namespace Microsoft.ContainerService
    az provider register -n Microsoft.ContainerService
    
  4. 建立 AKS 叢集以部署超集。

    # Create resource group
    az group create --location $REGION --name $RESOURCE_GROUP_NAME
    
    # Create AKS cluster
    az \
    aks create \
    -g $RESOURCE_GROUP_NAME \
    -n $CLUSTER_NAME \
    --node-vm-size Standard_DS2_v2 \
    --node-count 3 \
    --enable-managed-identity \
    --assign-identity $MANAGED_IDENTITY_RESOURCE \
    --assign-kubelet-identity $MANAGED_IDENTITY_RESOURCE
    
    # Set the context of your new Kubernetes cluster
    az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAME
    

部署 Apache Superset

  1. 若要讓 Superset 安全地與 Trino 叢集通訊,最簡單的方式是設定 Superset 以使用 Azure 受控識別。 此步驟表示叢集會使用您指派的身分識別,而不需手動部署或迴圈秘密。

    您必須為 Superset Helm 部署建立 values.yaml 檔案。 請參閱 範例程序代碼

    選擇性:使用 Microsoft Azure Postgres,而不是使用部署在 Kubernetes 叢集內的 Postgres。

    建立「適用於 PostgreSQL 的 Azure 資料庫」實例,以方便維護、允許備份,並提供更佳的可靠性。

    postgresql:
      enabled: false
    
    supersetNode:
      connections:
        db_host: '{{SERVER_NAME}}.postgres.database.azure.com'
        db_port: '5432'
        db_user: '{{POSTGRES_USER}}'
        db_pass: '{{POSTGRES_PASSWORD}}'
        db_name: 'postgres' # default db name for Azure Postgres
    
  2. 視需要新增 values.yaml 的其他區段。 超集文件 建議變更默認密碼。

  3. 使用 Helm 部署超集。

    # Verify you have the context of the right Kubernetes cluster
    kubectl cluster-info
    # Add the Superset repository
    helm repo add superset https://apache.github.io/superset
    # Deploy
    helm repo update
    helm upgrade --install --values values.yaml superset superset/superset
    
  4. 連線 至 Superset 並建立連線。

    注意

    您應該為每個您想要使用的 Trino 目錄建立個別的連線。

    1. 連線 使用埠轉送至超集。

      kubectl port-forward service/superset 8088:8088 --namespace default

    2. 開啟網頁瀏覽器並移至 http://localhost:8088/. 如果您未變更系統管理員密碼,請使用使用者名稱登入:admin、password:admin。

    3. 從右側的加號 『+』 選單中選取 [連接資料庫]。

      顯示線上資料庫的螢幕快照。

    4. 選取 [ Trino]。

    5. 輸入 Trino 叢集的 SQL Alchemy URI。

      您必須修改此 連接字串 的三個部分:

      屬性 範例 描述
      使用者 trino@ @ 符號之前的名稱是用來連線至 Trino 的用戶名稱。
      hostname mytrinocluster.0000000000000000000000000000
      .eastus.hdinsightaks.net
      Trino 叢集的主機名。
      您可以從叢集的 [概觀] 頁面,在 Azure 入口網站 取得此資訊。
      catalog /tpch 斜線之後,是預設目錄名稱。
      您必須將此目錄變更為具有您想要可視化之資料的目錄。

      trino://$USER@$TRINO_CLUSTER_HOST_NAME.hdinsightaks.net:443/$DEFAULT_CATALOG

      範例: trino://trino@mytrinocluster.00000000000000000000000000.westus3.hdinsightaks.net:443/tpch

      顯示 連接字串 的螢幕快照。

    6. 選取 [進階] 索引標籤,然後在 [其他安全性] 中輸入下列設定。將 client_id 值取代為受控識別的 GUID 用戶端識別碼(您可以在 Azure 入口網站 的受控識別資源概觀頁面中找到此值)。

       {
         "auth_method": "azure_msi",
         "auth_params":
         {
           "scope": "https://clusteraccess.hdinsightaks.net/.default",
           "client_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
         }
       }
      

      顯示新增 MSI 的螢幕快照。

    7. 選取 [連線]。

現在,您已準備好建立數據集和圖表。

疑難排解

  • 確認您的 Trino 叢集已設定為允許超集叢集的使用者指派受控識別進行連線。 您可以查看 Trino 叢集的資源 JSON 來確認此值(authorizationProfile/userIds)。 請確定您使用身分識別的物件識別碼,而不是用戶端識別碼。

  • 請確定連線設定中沒有任何錯誤。

    1. 請確定已填寫「安全額外」,
    2. 您的URL正確。
    3. tpch使用 目錄來測試 ,以確認您的連線在使用您自己的目錄之前是否正常運作。

後續步驟

若要將超集公開至因特網,請使用 Microsoft Entra ID 允許使用者登入,您需要完成下列一般步驟。 這些步驟需要 Kubernetes 的中繼或更高體驗。