Load Balancers - Create Or Update
在指定的受控叢集中建立或更新負載平衡器。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/loadBalancers/{loadBalancerName}?api-version=2025-05-02-preview
URI 參數
名稱 | 位於 | 必要 | 類型 | Description |
---|---|---|---|---|
load
|
path | True |
string minLength: 1maxLength: 12 pattern: ^[a-z][a-z0-9]{0,11}$ |
負載平衡器的名稱。 |
resource
|
path | True |
string minLength: 1maxLength: 90 |
資源群組的名稱。 名稱不區分大小寫。 |
resource
|
path | True |
string minLength: 1maxLength: 63 pattern: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$ |
受控叢集資源的名稱。 |
subscription
|
path | True |
string (uuid) |
目標訂用帳戶的標識碼。 此值必須是 UUID。 |
api-version
|
query | True |
string minLength: 1 |
要用於這項作業的 API 版本。 |
要求本文
名稱 | 必要 | 類型 | Description |
---|---|---|---|
properties.primaryAgentPoolName | True |
string |
必要欄位。 字串值,必須指定現有代理程式集區的標識碼。 指定集區中的所有節點一律會新增至此負載平衡器。 此代理程式集區必須至少有一個節點,minCount>=1 才能自動調整作業。 代理程式集區只能是單一負載平衡器的主要集區。 |
properties.allowServicePlacement |
boolean |
是否要自動將服務放在負載平衡器上。 如果未提供,預設值為 true。 如果手動設定為 false,除非外部和內部負載平衡器明確將其設為目標,否則不會針對服務選取。 |
|
properties.nodeSelector |
符合此選取器的節點將是此負載平衡器可能的成員。 |
||
properties.serviceLabelSelector |
只有必須符合此選取器的服務才能放在此負載平衡器上。 |
||
properties.serviceNamespaceSelector |
在符合選取器之命名空間中建立的服務可以放在此負載平衡器上。 |
回應
名稱 | 類型 | Description |
---|---|---|
200 OK |
現有的負載平衡器已成功更新 |
|
201 Created |
已成功建立新的負載平衡器 |
|
Other Status Codes |
說明作業為何失敗的錯誤回應。 |
安全性
azure_auth
Azure Active Directory OAuth2 流
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
名稱 | Description |
---|---|
user_impersonation | 模擬您的用戶帳戶 |
範例
Create or update a Load Balancer
範例要求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/loadBalancers/kubernetes?api-version=2025-05-02-preview
{
"properties": {
"primaryAgentPoolName": "agentpool1",
"allowServicePlacement": true
}
}
範例回覆
{
"name": "kubernetes",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/loadBalancers/kubernetes",
"properties": {
"primaryAgentPoolName": "agentPool1",
"allowServicePlacement": true,
"provisioningState": "Succeeded"
}
}
{
"name": "kubernetes",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/loadBalancers/kubernetes",
"properties": {
"primaryAgentPoolName": "agentPool1",
"allowServicePlacement": true,
"provisioningState": "Succeeded"
}
}
定義
名稱 | Description |
---|---|
Cloud |
來自容器服務的錯誤回應。 |
Cloud |
來自容器服務的錯誤回應。 |
created |
建立資源的身分識別類型。 |
Label |
標籤選取器是一組資源的標籤查詢。 matchLabels 和 matchExpressions 的結果為 ANDed。 空白標籤選取器符合所有物件。 Null 標籤選取器不符任何物件。 |
Label |
卷標選取器需求是一種選取器,其中包含值、索引鍵,以及關聯索引鍵和值的運算符。 |
Load |
關於多個標準負載平衡器的設定。 如果未提供,則會使用單一負載平衡器模式。 如果在租用時提供一個設定,將會使用多個標準負載平衡器模式。 必須有名為 |
operator |
運算子代表索引鍵與一組值的關聯性。 有效運算子為 In 和 NotIn |
system |
與建立和上次修改資源相關的元數據。 |
CloudError
來自容器服務的錯誤回應。
名稱 | 類型 | Description |
---|---|---|
error |
錯誤的詳細數據。 |
CloudErrorBody
來自容器服務的錯誤回應。
名稱 | 類型 | Description |
---|---|---|
code |
string |
錯誤的識別碼。 程序代碼是不變的,而且是要以程序設計方式取用。 |
details |
錯誤的其他詳細數據清單。 |
|
message |
string |
描述錯誤的訊息,適用於在使用者介面中顯示。 |
target |
string |
特定錯誤的目標。 例如,錯誤中的屬性名稱。 |
createdByType
建立資源的身分識別類型。
值 | Description |
---|---|
User | |
Application | |
ManagedIdentity | |
Key |
LabelSelector
標籤選取器是一組資源的標籤查詢。 matchLabels 和 matchExpressions 的結果為 ANDed。 空白標籤選取器符合所有物件。 Null 標籤選取器不符任何物件。
名稱 | 類型 | Description |
---|---|---|
matchExpressions |
matchExpressions 是標籤選取器需求的清單。 需求為 ANDed。 |
|
matchLabels |
string[] |
matchLabels 是 {key=value} 組的陣列。 matchLabels 對應中的單一 {key=value} 相當於 matchExpressions 的專案,其索引鍵字段為 |
LabelSelectorRequirement
卷標選取器需求是一種選取器,其中包含值、索引鍵,以及關聯索引鍵和值的運算符。
名稱 | 類型 | Description |
---|---|---|
key |
string |
key 是選取器所套用的標籤索引鍵。 |
operator |
運算子代表索引鍵與一組值的關聯性。 有效運算子為 In 和 NotIn |
|
values |
string[] |
values 是字串值的陣列,值陣列必須是非空白的。 |
LoadBalancer
關於多個標準負載平衡器的設定。 如果未提供,則會使用單一負載平衡器模式。 如果在租用時提供一個設定,將會使用多個標準負載平衡器模式。 必須有名為 kubernetes
的組態。 名稱欄位會是對應公用負載平衡器的名稱。 如有需要,將會建立內部負載平衡器,且名稱會是 <name>-internal
。 內部 lb 共用與外部 lb 相同的組態。 LoadBalancer 清單中不需要包含內部 lbs。
名稱 | 類型 | Description |
---|---|---|
id |
string (arm-id) |
資源的完整資源標識碼。 例如 “/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}” |
name |
string |
資源的名稱 |
properties.allowServicePlacement |
boolean |
是否要自動將服務放在負載平衡器上。 如果未提供,預設值為 true。 如果手動設定為 false,除非外部和內部負載平衡器明確將其設為目標,否則不會針對服務選取。 |
properties.nodeSelector |
符合此選取器的節點將是此負載平衡器可能的成員。 |
|
properties.primaryAgentPoolName |
string |
必要欄位。 字串值,必須指定現有代理程式集區的標識碼。 指定集區中的所有節點一律會新增至此負載平衡器。 此代理程式集區必須至少有一個節點,minCount>=1 才能自動調整作業。 代理程式集區只能是單一負載平衡器的主要集區。 |
properties.provisioningState |
string |
目前的布建狀態。 |
properties.serviceLabelSelector |
只有必須符合此選取器的服務才能放在此負載平衡器上。 |
|
properties.serviceNamespaceSelector |
在符合選取器之命名空間中建立的服務可以放在此負載平衡器上。 |
|
systemData |
包含 createdBy 和 modifiedBy 資訊的 Azure Resource Manager 元數據。 |
|
type |
string |
資源的類型。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts” |
operator
運算子代表索引鍵與一組值的關聯性。 有效運算子為 In 和 NotIn
值 | Description |
---|---|
In |
索引鍵的值應該位於指定的清單中。 |
NotIn |
索引鍵的值不應該在指定的清單中。 |
Exists |
索引鍵的值應該存在。 |
DoesNotExist |
索引鍵的值不應該存在。 |
systemData
與建立和上次修改資源相關的元數據。
名稱 | 類型 | Description |
---|---|---|
createdAt |
string (date-time) |
資源建立的時間戳(UTC)。 |
createdBy |
string |
建立資源的身分識別。 |
createdByType |
建立資源的身分識別類型。 |
|
lastModifiedAt |
string (date-time) |
上次修改的資源時間戳 (UTC) |
lastModifiedBy |
string |
上次修改資源的身分識別。 |
lastModifiedByType |
上次修改資源的身分識別類型。 |