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

Important

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

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

先決條件

設定環境變數

  • 為你的 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 叢集:

如果你已有符合這些需求的叢集,可以跳過這個步驟。

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

    az group create --name $AKS_RG --location $LOCATION 
    
  2. 使用 az aks create 命令搭配 --enable-oidc-issuer、--enable-aad 與 --enable-gateway-api 旗標,建立啟用 AKS 受控 Microsoft Entra 整合、OIDC 發行者及受控 Kubernetes Gateway API 增益集的 AKS 叢集。 請勿在此叢集啟用 Istio 服務網狀附加元件--enable-azure-service-mesh()。

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

建立 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 參數設為 FullyManaged 或 SelfManaged的指令,加入 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-waypoint、istio.io/use-waypoint-namespace 和 istio.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 應用網路的資訊,請參閱以下文章: