教學課程:使用 Azure Linux 搭配 Azure Kubernetes Service (AKS) 的 OS Guard (預覽) 建立叢集

Important

自 2026 年 12 月 10 日起,Azure Kubernetes Service (AKS) 不再支援 Azure Linux 搭配 OS Guard for AKS(預覽版)。 此時,AKS 將不再生產新的 Azure Linux 搭配 OS Guard 節點映像檔,也不再提供安全修補程式,且你也無法再用 Azure Linux 搭配 OS Guard 建立新的節點池。 2027 年 3 月 10 日,AKS 移除所有現有的 Azure Linux 與 OS Guard 節點映像,導致擴展與修復(重映像化與重新部署)操作失敗。 為避免中斷,請遷移至 Azure Container Linux(ACL)。 欲了解更多關於退休的資訊,請參閱退休 GitHub 議題及 Azure 更新退休公告。 想隨時掌握公告與更新,請參考 AKS 發布說明。

Note

Azure Linux 搭配 OS Guard(預覽版)正被 Azure Container Linux(ACL)取代。

Azure Container Linux 是 Azure Kubernetes Service (AKS) 的長期、不可變、容器優化的 Linux 作業系統(OS)。 它提供一個安全、簡約且操作一致的主機作業系統,設計用以大規模執行容器化工作負載。

欲了解更多資訊,請參閱 Azure容器 Linux(ACL)概述。

在本教學的 五部分中的第一部分中,你將學習如何:

  • 安裝 Kubernetes CLI:kubectl。
  • 安裝 aks-preview Azure CLI 延伸模組。
  • 註冊 AzureLinuxOSGuardPreview 功能旗標。
  • 建立 Azure 資源群組。
  • 建立並部署具有 OS Guard 叢集的 Azure Linux。
  • 設定 kubectl 為使用 OS Guard 叢集連線到 Azure Linux。

在稍後的教學課程中,您將瞭解如何將具有 OS Guard 節點集區的 Azure Linux 新增至現有的叢集,並將現有的節點移轉至具有 OS Guard 的 Azure Linux。

先決條件

Azure Linux with OS Guard 的考量因素與限制

開始之前,請檢閱下列針對具有 OS Guard 的 Azure Linux 的注意事項及限制(預覽):

安裝 aks-preview Azure CLI 擴充功能

Important

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

使用 aks-preview 命令安裝 az extension add 延伸模組。

az extension add --name aks-preview

使用 az extension update 命令,更新為最新版的延伸模組。

az extension update --name aks-preview

註冊 AzureLinuxOSGuardPreview 功能旗標

  1. 使用 AzureLinuxOSGuardPreview 命令註冊 az feature register 功能旗標。

    az feature register --namespace "Microsoft.ContainerService" --name "AzureLinuxOSGuardPreview"
    

    狀態需要幾分鐘的時間才會顯示「已註冊」。

  2. 使用 az feature show 命令驗證註冊狀態。

    az feature show --namespace "Microsoft.ContainerService" --name "AzureLinuxOSGuardPreview"
    
  3. 當狀態顯示為已註冊時,請使用Microsoft.ContainerService命令來重新整理az provider register資源提供者的註冊。

    az provider register --namespace "Microsoft.ContainerService"
    

設定環境變數

設定以下環境變數,為每個部署建立獨特的資源名稱:

export RESOURCE_GROUP="<your-resource-group-name>"
export REGION="<your-region>"
export CLUSTER_NAME="<your-cluster-name>"

建立資源群組

在 Azure 建立資源群組時,你必須指定一個位置。 這個位置是你資源群組元資料的儲存位置,也是如果你在建立資源時沒有指定其他區域,資源在 Azure 中會執行的位置。

使用 az group create 命令建立資源群組。

az group create --name $RESOURCE_GROUP --location $REGION

輸出範例:

{
  "id": "/subscriptions/xxxxx/resourceGroups/testAzureLinuxOSGuardResourceGroupxxxxx",
  "location": "EastUS2",
  "managedBy": null,
  "name": "testAzureLinuxOSGuardResourceGroupxxxxx",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null,
  "type": "Microsoft.Resources/resourceGroups"
}

使用 OS Guard (預覽) 叢集建立 Azure Linux

使用az aks create命令和--os-sku AzureLinuxOSGuard參數來建立 AKS 叢集,以布建包含 OS Guard 的 Azure Linux 叢集。 使用搭配 OS Guard 的 Azure Linux 時,必須啟用 FIPS、安全開機 和 vTPM。

az aks create --name $CLUSTER_NAME --resource-group $RESOURCE_GROUP --os-sku AzureLinuxOSGuard --node-osdisk-type Managed --enable-fips-image --enable-secure-boot --enable-vtpm

輸出範例:

{
  "id": "/subscriptions/xxxxx/resourceGroups/testAzureLinuxOSGuardResourceGroupxxxxx/providers/Microsoft.ContainerService/managedClusters/testAzureLinuxOSGuardClusterxxxxx",
  "location": "WestUS2",
  "name": "testAzureLinuxOSGuardClusterxxxxx",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "type": "Microsoft.ContainerService/managedClusters"
}

幾分鐘後,命令會完成並傳回關於叢集的 JSON 格式資訊。

使用 kubectl 連線到叢集

  1. 設定 kubectl 使用 az aks get-credentials 命令連線到 Kubernetes 叢集。

    az aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME
    
  2. 使用命令 kubectl get nodes 驗證叢集的連線,以傳回叢集節點清單。

    kubectl get nodes
    

    輸出範例:

    NAME                           STATUS   ROLES   AGE     VERSION
    aks-nodepool1-00000000-0       Ready    agent   10m     v1.20.7
    aks-nodepool1-00000000-1       Ready    agent   10m     v1.20.7
    

後續步驟

在本教學課程中,您已建立並部署具有 OS Guard 叢集的 Azure Linux。 在下一個教學課程中,您將瞭解如何將具有 OS Guard 節點集區的 Azure Linux 新增至現有的叢集。