開始使用 Azure Kubernetes Application Network for AKS (預覽)

Important

AKS 預覽功能可透過自願加入的方式使用。 預覽是「依現況」及「可用時」提供的,並不包括在服務等級協定和有限保固之內。 客戶支援部門會盡最大努力,部分支援 AKS 預覽。 因此,這些功能不適合實際執行用途。 如需詳細資訊,請參閱下列支援文章:

本文將幫助你開始使用 AKS 的 Azure Kubernetes Application Network。 它提供逐步說明,如何建立應用網路資源,並將 AKS 叢集作為成員叢集連接到該資源。

先決條件

  • Azure 訂用帳戶。 如果您沒有帳戶,請建立 免費帳戶
  • Azure CLI 版本 2.84.0 或更新版本。 使用 az --version 命令來檢查您的版本。 要安裝或更新,請參見 安裝 Azure CLI
  • 若使用現有的 AKS 叢集,請確保已啟用 AKS 管理的 Microsoft Entra 整合 OIDC 發行者。 這些功能是 Azure Kubernetes 應用網路連接與安全性所必需的。
  • 請使用 支援政策驗證你現有 Kubernetes 叢集的支援。

設定環境變數

  • 為你的 Azure Kubernetes 應用網路資源與叢集設定以下環境變數。 你可以先使用現有叢集,或在後續步驟建立叢集 ,再加入 Azure Kubernetes 應用網路。

    export SUBSCRIPTION=<subscription-id>
    export LOCATION=<location>
    export APPNET_RG=<resource-group-for-appnet-resource>
    export APPNET_NAME=<appnet-name>
    export APPNET_MEMBER_NAME=<appnet-member-name>
    export AKS_RG=<aks-cluster-resource-group>
    export CLUSTER_NAME=<cluster-name>
    

註冊此功能以供公開預覽

  1. 請使用 指令 az feature register 註冊 Azure Kubernetes Application Network 的功能。

    az feature register --namespace Microsoft.AppLink --name PublicPreview --subscription $SUBSCRIPTION
    
  2. 請等待功能註冊完成。 你可以用指令 az feature show 查詢狀態。

    az feature show --namespace Microsoft.AppLink --name PublicPreview --subscription $SUBSCRIPTION
    

    properties.state當註冊完成時,輸出欄位會顯示Registered

  3. 功能註冊後,請使用指令 az provider register 重新註冊 Microsoft.AppLink 資源提供者。

    az provider register --namespace Microsoft.AppLink --subscription $SUBSCRIPTION
    

安裝 AppNet CLI 擴充功能

  • 請使用指令 az extension add 安裝 AppNet CLI 擴充功能。

    az extension add --name appnet-preview
    

設定有效訂閱

  • 使用az account set命令將作用中訂用帳戶設定為您想用於 Azure Kubernetes 應用程式網路的訂用帳戶。

    az account set --subscription $SUBSCRIPTION 
    

建立 AKS 叢集

備註

成員叢集 不需要 分開在不同的資源群組裡。 它們可以與 Azure Kubernetes 應用網路資源在同一個資源群組中。 然而,所有成員叢集必須在同一租戶中。

如果你沒有現有的 AKS 叢集可以連接到 Azure Kubernetes 應用網路,你需要自己建立一個。 Azure Kubernetes 應用程式網路需要具有 AKS 管理的 Microsoft Entra 整合和已啟用 OIDC 核發者的 AKS 叢集。 如果你已有叢集,可以跳過這個步驟。

  1. 使用 這個 az group create 指令為你的 AKS 叢集建立資源群組。

    az group create --name $AKS_RG --location $LOCATION 
    
  2. 使用az aks create命令搭配--enable-oidc-issuer--enable-aad旗標,建立一個具有 AKS 管理的 Microsoft Entra 整合並已啟用 OIDC 核發者的AKS 叢集。

    az aks create --name $CLUSTER_NAME --resource-group $AKS_RG --enable-oidc-issuer --enable-aad
    

建立 Azure Kubernetes 應用程式網路資源

  1. 請使用 命令 az group create 為你的 Azure Kubernetes Application Network 資源建立資源群組。

    az group create --name $APPNET_RG --location $LOCATION 
    
  2. 請使用 命令 az appnet create 建立 Azure Kubernetes 應用網路資源。

    az appnet create --resource-group $APPNET_RG --name $APPNET_NAME --location $LOCATION  --identity-type SystemAssigned
    

    創建過程可能需要幾分鐘。 輸出的properties.provisioningState欄位為成功建立的 Azure Kubernetes 應用程式網路顯示Succeeded

  3. 請使用 指令 az appnet show 查看您的 Azure Kubernetes 應用網路資源。

    az appnet show --resource-group $APPNET_RG --name $APPNET_NAME
    

加入 AKS 叢集,成為 Azure Kubernetes Application Network 的成員

當您加入成員叢集到 Azure Kubernetes 應用網路時,您可以為該叢集指定以下升級模式之一: 全管理自我管理。 升級模式決定了 Azure Kubernetes 應用網路的次要版本升級如何套用到成員叢集。 如果你在會員加入時沒有指定升級模式,它就會預設為 SelfManaged。 欲了解更多升級模式資訊,請參閱 「為 Azure Kubernetes 應用網路成員配置升級」。

  • 使用 az appnet member join--upgrade-mode 參數設為 FullyManagedSelfManaged的指令,加入 AKS 叢集,成為 Azure Kubernetes 應用網路的成員。 以下範例顯示如何以SelfManaged模式加入成員叢集:

    az appnet member join \
        --resource-group $APPNET_RG \
        --appnet-name $APPNET_NAME \
        --member-name $APPNET_MEMBER_NAME \
        --member-resource-id /subscriptions/$SUBSCRIPTION/resourcegroups/$AKS_RG/providers/Microsoft.ContainerService/managedClusters/$CLUSTER_NAME \
        --upgrade-mode SelfManaged
    

驗證成員叢集的連接性

  • 加入叢集後,你可以用指令 az appnet member show 驗證連線並查看成員詳細資料。

    az appnet member show --resource-group $APPNET_RG --appnet-name $APPNET_NAME --member-name $APPNET_MEMBER_NAME
    

    例如,若以全管理模式註冊並搭配 Stable 釋放通道,輸出會呈現如下:

    {
      "id": "/subscriptions/$SUBSCRIPTION/resourceGroups/$APPNET_RG/providers/Microsoft.AppLink/appLinks/$APPNET_NAME/appLinkMembers/$APPNET_MEMBER_NAME",
      "location": "myLocation",
      "name": "myMemberName",
      "properties": {
        "clusterType": "AKS",
        "connectivityProfile": {
          "eastWestGateway": {
            "visibility": "Internal"
          }
        },
        "metadata": {
          "resourceId": "/subscriptions/$SUBSCRIPTION/resourcegroups/$AKS_RG/providers/Microsoft.ContainerService/managedClusters/$CLUSTER_NAME"
        },
        "observabilityProfile": {
          "metrics": {
            "metricsEndpoint": "https://myMember-mcp-fqdn.appnet.net"
          }
        },
        "provisioningState": "Succeeded",
        "upgradeProfile": {
          "mode": "FullyManaged",
          "fullyManagedUpgradeProfile": {
            "releaseChannel": "Stable"
          }
        }
      },
      "resourceGroup": "myAppNetRG",
      "type": "microsoft.applink/applinks/applinkmembers"
    }
    

列出 Azure Kubernetes Application Network 成員

多個叢集可以加入 Azure Kubernetes 應用網路。

  • 使用 該 az appnet member list 指令列出 Azure Kubernetes 應用網路的所有成員。

    az appnet member list --resource-group $APPNET_RG --appnet-name $APPNET_NAME --output table
    

刪除 Azure Kubernetes 應用程式網絡資源

您必須先移除所有成員,才能刪除 Azure Kubernetes 應用程式網路資源。 移除成員並不會刪除對應的 AKS 叢集。

移除 Azure Kubernetes Application Network 成員

備註

在移除成員之前,您必須先移除資源中您先前套用的 Istio 標籤(如 istio.io/use-waypointistio.io/use-waypoint-namespaceistio.io/dataplane-mode),以便將工作負載從環境資料平面中移除。

  1. 請使用 命令 az appnet member remove 移除 Azure Kubernetes 應用網路中的成員。

    az appnet member remove --resource-group $APPNET_RG --appnet-name $APPNET_NAME --member-name $APPNET_MEMBER_NAME
    
  2. 請用指令 az appnet member list 確認該成員已被移除。

    az appnet member list --resource-group $APPNET_RG --appnet-name $APPNET_NAME 
    

刪除 Azure Kubernetes 應用程式網路資源

  • 請使用 指令 az appnet delete 刪除 Azure Kubernetes 應用程式網路資源。

    az appnet delete --resource-group $APPNET_RG --appnet-name $APPNET_NAME
    

欲了解更多關於 Azure Kubernetes 應用網路的資訊,請參閱以下文章: