适用于: ✔️车队经理 ✔️中心群集的车队经理
了解如何使用 Bicep 创建 Azure Kubernetes Fleet Manager。
在您开始之前
如果您还没有 Azure 试用订阅,请在开始之前创建一个试用订阅。
创建舰队管理器
可以创建一个机群管理器,然后添加 AKS 和已启用 Arc 的群集作为成员群集。 如果 Fleet Manager 具有中心群集,则已启用更多功能,例如 Kubernetes 对象传播 和 托管机群命名空间。 有关详细信息,请参阅 机群管理器类型的概念性概述,其中提供了不同机群管理器配置的比较。
重要
创建机群管理器后,可以将不带中心群集的 Fleet Manager 资源升级到具有中心群集的资源。 对于具有中心群集的机群管理器资源,选择专用或公共资源后,无法更改它。
如果只想对更新业务流程使用舰队管理器,则可以使用以下 Bicep 创建无中心舰队管理器:
审查 Bicep
@description('The name of the Fleet resource.')
param fleetName string = 'my-hubless-fleet'
@description('The location of the Fleet resource.')
param location string = resourceGroup().location
resource hubless_fleet 'Microsoft.ContainerService/fleets@2025-03-01' = {
name: fleetName
location: location
}
使用 Azure CLI 或 Azure PowerShell 来部署该 Bicep 文件。
请将 Bicep 文件保存到您的本地计算机,并命名为 main.bicep。
使用 Azure CLI 或 Azure PowerShell 来部署该 Bicep 文件。
az group create --name myResourceGroup --location chinanorth3
az deployment group create --resource-group myResourceGroup --template-file main.bicep'
New-AzResourceGroup -Name myResourceGroup -Location chinanorth3
New-AzResourceGroupDeployment -ResourceGroupName myResourceGroup -TemplateFile ./main.bicep"
如果除了更新业务流程之外,还想要使用 Fleet Manager 进行 Kubernetes 对象传播,则需要使用中心群集创建 Fleet Manager 资源。
具有中心群集的机群管理器支持用于网络访问的公共模式和专用模式。 有关详细信息,请参阅 “选择 Azure Kubernetes Fleet Manager”选项。
公共中心群集
若要创建带有中心群集的公共舰队管理器资源,请使用以下 Bicep
审查 Bicep
@description('The name of the Fleet resource.')
param fleetName string = 'my-hubful-fleet'
@description('The location of the Fleet resource.')
param location string = resourceGroup().location
resource hubful_fleet 'Microsoft.ContainerService/fleets@2025-03-01' = {
name: fleetName
location: location
properties: {
hubProfile: {
dnsPrefix: fleetName
}
}
}
使用 Azure CLI 或 Azure PowerShell 来部署该 Bicep 文件。
请将 Bicep 文件保存到您的本地计算机,并命名为 main.bicep。
使用 Azure CLI 或 Azure PowerShell 来部署该 Bicep 文件。
az group create --name myResourceGroup --location chinanorth3
az deployment group create --resource-group myResourceGroup --template-file main.bicep'
New-AzResourceGroup -Name myResourceGroup -Location chinanorth3
New-AzResourceGroupDeployment -ResourceGroupName myResourceGroup -TemplateFile ./main.bicep"
专用中心群集
使用专用中心群集创建 Fleet Manager 时,请考虑到以下其他注意事项:
- 机群管理器要求您指定用于放置Fleet Manager中心集群节点虚拟机(VM)的子网。 这可以通过在舰队管理器的
subnetId 的 agentProfile 中设置 hubProfile 来完成。
-
vnet vnetName 的地址前缀不得与 Azure Kubernetes 服务的 (AKS) 默认服务范围
10.0.0.0/16重叠。
- 专用访问模式不允许配置域名。
- 专用访问模式需要在代理子网上为舰队管理器的第一方服务主体分配
Network Contributor 角色(舰队管理器的第一方服务主体 ID 在不同的 Entra 租户之间有所不同)。 使用命令创建专用机群管理器时az fleet create此角色分配,因为 CLI 会自动创建角色分配。
- 提取舰队管理器的服务主体对象 ID:
az ad sp list \
--display-name "Azure Kubernetes Service - Fleet RP" \
--query "[].{id:id}" \
--output tsv
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- 审查 Bicep
@description('The name of the vnet.')
param vnetName string = 'myVnet'
@description('The name of the Fleet resource.')
param fleetName string = 'my-private-fleet'
@description('The object id of Fleets Service Principal in your tenant.')
param fleetSpObjectId string = '00000000-0000-0000-0000-000000000000' // Replace with the actual object ID of the Fleets Service Principal
@description('The location of the Fleet resource.')
param location string = resourceGroup().location
resource vnet 'Microsoft.Network/virtualNetworks@2024-05-01' = {
name: vnetName
location: location
properties: {
addressSpace: {
addressPrefixes: [
'192.168.0.0/16'
]
}
}
}
resource hubful_private_fleet 'Microsoft.ContainerService/fleets@2025-03-01' = {
name: fleetName
location: location
properties: {
hubProfile: {
agentProfile: {
subnetId: vnet_subnet.id
}
apiServerAccessProfile: {
enablePrivateCluster: true
enableVnetIntegration: false
}
}
}
dependsOn: [
roleassignment
]
}
resource vnet_subnet 'Microsoft.Network/virtualNetworks/subnets@2024-05-01' = {
name: 'subnet'
properties: {
addressPrefix: '192.168.0.0/24'
delegations: []
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
parent: vnet
}
resource roleassignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: vnet_subnet
name: guid(vnet_subnet.id, fleetSpObjectId)
properties: {
roleDefinitionId: subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions',
'4d97b98b-1d4f-4787-a291-c67834d212e7'
)
principalId: fleetSpObjectId
principalType: 'ServicePrincipal'
}
}
- 使用 Azure CLI 或 Azure PowerShell 来部署该 Bicep 文件。
部署第一步中带有服务主体对象 ID 的 Bicep 文件:
后续步骤