Creates or updates an agent pool in the specified managed cluster.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/agentPools/{agentPoolName}?api-version=2024-08-01
URI Parameters
Name |
In |
Required |
Type |
Description |
agentPoolName
|
path |
True
|
string
|
The name of the agent pool.
Regex pattern: ^[a-z][a-z0-9]{0,11}$
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group. The name is case insensitive.
|
resourceName
|
path |
True
|
string
|
The name of the managed cluster resource.
Regex pattern: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$
|
subscriptionId
|
path |
True
|
string
uuid
|
The ID of the target subscription. The value must be an UUID.
|
api-version
|
query |
True
|
string
|
The API version to use for this operation.
|
Request Body
Name |
Type |
Description |
properties.availabilityZones
|
string[]
|
The list of Availability zones to use for nodes. This can only be specified if the AgentPoolType property is 'VirtualMachineScaleSets'.
|
properties.capacityReservationGroupID
|
string
|
The fully qualified resource ID of the Capacity Reservation Group to provide virtual machines from a reserved group of Virtual Machines.
AKS will associate the specified agent pool with the Capacity Reservation Group.
|
properties.count
|
integer
|
Number of agents (VMs) to host docker containers. Allowed values must be in the range of 0 to 1000 (inclusive) for user pools and in the range of 1 to 1000 (inclusive) for system pools. The default value is 1.
|
properties.creationData
|
CreationData
|
CreationData to be used to specify the source Snapshot ID if the node pool will be created/upgraded using a snapshot.
|
properties.enableAutoScaling
|
boolean
|
Whether to enable auto-scaler
|
properties.enableEncryptionAtHost
|
boolean
|
Whether to enable host based OS and data drive encryption.
This is only supported on certain VM sizes and in certain Azure regions. For more information, see: https://docs.microsoft.com/azure/aks/enable-host-encryption
|
properties.enableFIPS
|
boolean
|
Whether to use a FIPS-enabled OS.
See Add a FIPS-enabled node pool for more details.
|
properties.enableNodePublicIP
|
boolean
|
Whether each node is allocated its own public IP.
Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node. The default is false.
|
properties.enableUltraSSD
|
boolean
|
Whether to enable UltraSSD
|
properties.gpuInstanceProfile
|
GPUInstanceProfile
|
GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
|
properties.hostGroupID
|
string
|
The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.
This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}. For more information see Azure dedicated hosts.
|
properties.kubeletConfig
|
KubeletConfig
|
Kubelet configurations of agent nodes.
The Kubelet configuration on the agent pool nodes.
|
properties.kubeletDiskType
|
KubeletDiskType
|
Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.
|
properties.linuxOSConfig
|
LinuxOSConfig
|
OS configurations of Linux agent nodes.
The OS configuration of Linux agent nodes.
|
properties.maxCount
|
integer
|
The maximum number of nodes for auto-scaling
|
properties.maxPods
|
integer
|
The maximum number of pods that can run on a node.
|
properties.minCount
|
integer
|
The minimum number of nodes for auto-scaling
|
properties.mode
|
AgentPoolMode
|
The mode of an agent pool.
A cluster must have at least one 'System' Agent Pool at all times. For additional information on agent pool restrictions and best practices, see: https://docs.microsoft.com/azure/aks/use-system-pools
|
properties.networkProfile
|
AgentPoolNetworkProfile
|
Network-related settings of an agent pool.
|
properties.nodeLabels
|
object
|
The node labels to be persisted across all nodes in agent pool.
|
properties.nodePublicIPPrefixID
|
string
|
The public IP prefix ID which VM nodes should use IPs from.
This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPPrefixes/{publicIPPrefixName}
|
properties.nodeTaints
|
string[]
|
The taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule.
|
properties.orchestratorVersion
|
string
|
The version of Kubernetes specified by the user.
Both patch version <major.minor.patch> (e.g. 1.20.13) and <major.minor> (e.g. 1.20) are supported. When <major.minor> is specified, the latest supported GA patch version is chosen automatically. Updating the cluster with the same <major.minor> once it has been created (e.g. 1.14.x -> 1.14) will not trigger an upgrade, even if a newer patch version is available. As a best practice, you should upgrade all node pools in an AKS cluster to the same Kubernetes version. The node pool version must have the same major version as the control plane. The node pool minor version must be within two minor versions of the control plane version. The node pool version cannot be greater than the control plane version. For more information see upgrading a node pool.
|
properties.osDiskSizeGB
|
integer
|
OS Disk Size in GB to be used to specify the disk size for every machine in the master/agent pool. If you specify 0, it will apply the default osDisk size according to the vmSize specified.
|
properties.osDiskType
|
OSDiskType
|
The OS disk type to be used for machines in the agent pool.
The default is 'Ephemeral' if the VM supports it and has a cache disk larger than the requested OSDiskSizeGB. Otherwise, defaults to 'Managed'. May not be changed after creation. For more information see Ephemeral OS.
|
properties.osSKU
|
OSSKU
|
Specifies the OS SKU used by the agent pool. The default is Ubuntu if OSType is Linux. The default is Windows2019 when Kubernetes <= 1.24 or Windows2022 when Kubernetes >= 1.25 if OSType is Windows.
|
properties.osType
|
OSType
|
The operating system type. The default is Linux.
|
properties.podSubnetID
|
string
|
The ID of the subnet which pods will join when launched.
If omitted, pod IPs are statically assigned on the node subnet (see vnetSubnetID for more details). This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
|
properties.powerState
|
PowerState
|
Whether the Agent Pool is running or stopped.
When an Agent Pool is first created it is initially Running. The Agent Pool can be stopped by setting this field to Stopped. A stopped Agent Pool stops all of its VMs and does not accrue billing charges. An Agent Pool can only be stopped if it is Running and provisioning state is Succeeded
|
properties.proximityPlacementGroupID
|
string
|
The ID for Proximity Placement Group.
|
properties.scaleDownMode
|
ScaleDownMode
|
The scale down mode to use when scaling the Agent Pool.
This also effects the cluster autoscaler behavior. If not specified, it defaults to Delete.
|
properties.scaleSetEvictionPolicy
|
ScaleSetEvictionPolicy
|
The Virtual Machine Scale Set eviction policy to use.
This cannot be specified unless the scaleSetPriority is 'Spot'. If not specified, the default is 'Delete'.
|
properties.scaleSetPriority
|
ScaleSetPriority
|
The Virtual Machine Scale Set priority. If not specified, the default is 'Regular'.
|
properties.securityProfile
|
AgentPoolSecurityProfile
|
The security settings of an agent pool.
|
properties.spotMaxPrice
|
number
|
The max price (in US Dollars) you are willing to pay for spot instances. Possible values are any decimal value greater than zero or -1 which indicates default price to be up-to on-demand.
Possible values are any decimal value greater than zero or -1 which indicates the willingness to pay any on-demand price. For more details on spot pricing, see spot VMs pricing
|
properties.tags
|
object
|
The tags to be persisted on the agent pool virtual machine scale set.
|
properties.type
|
AgentPoolType
|
The type of Agent Pool.
|
properties.upgradeSettings
|
AgentPoolUpgradeSettings
|
Settings for upgrading the agentpool
|
properties.vmSize
|
string
|
The size of the agent pool VMs.
VM size availability varies by region. If a node contains insufficient compute resources (memory, cpu, etc) pods might fail to run correctly. For more details on restricted VM sizes, see: https://docs.microsoft.com/azure/aks/quotas-skus-regions
|
properties.vnetSubnetID
|
string
|
The ID of the subnet which agent pool nodes and optionally pods will join on startup.
If this is not specified, a VNET and subnet will be generated and used. If no podSubnetID is specified, this applies to nodes and pods, otherwise it applies to just nodes. This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
|
properties.windowsProfile
|
AgentPoolWindowsProfile
|
The Windows agent pool's specific profile.
|
properties.workloadRuntime
|
WorkloadRuntime
|
Determines the type of workload a node can run.
|
Responses
Name |
Type |
Description |
200 OK
|
AgentPool
|
The existing agent pool was successfully updated.
|
201 Created
|
AgentPool
|
The new agent pool was successfully created.
|
Other Status Codes
|
CloudError
|
Error response describing why the operation failed.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
Create Agent Pool using an agent pool snapshot
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"enableFIPS": true,
"creationData": {
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.CreationData;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_Snapshot.json
*/
/**
* Sample code: Create Agent Pool using an agent pool snapshot.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolUsingAnAgentPoolSnapshot(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools()
.createOrUpdate("rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3)
.withVmSize("Standard_DS2_v2").withOsType(OSType.LINUX).withOrchestratorVersion("").withEnableFips(true)
.withCreationData(new CreationData().withSourceResourceId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_snapshot.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"creationData": {
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
},
"enableFIPS": True,
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Snapshot.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Snapshot.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolUsingAnAgentPoolSnapshot() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
CreationData: &armcontainerservice.CreationData{
SourceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"),
},
EnableFIPS: to.Ptr(true),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CreationData: &armcontainerservice.CreationData{
// SourceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"),
// },
// CurrentOrchestratorVersion: to.Ptr("1.19.6"),
// EnableFIPS: to.Ptr(true),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.19.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Snapshot.json
*/
async function createAgentPoolUsingAnAgentPoolSnapshot() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
creationData: {
sourceResourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1",
},
enableFips: true,
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.19.6",
"currentOrchestratorVersion": "1.19.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableFIPS": true,
"creationData": {
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.19.6",
"currentOrchestratorVersion": "1.19.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableFIPS": true,
"creationData": {
"sourceResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"
}
}
}
Create Agent Pool with Capacity Reservation Group
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"capacityReservationGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_CRG.json
*/
/**
* Sample code: Create Agent Pool with Capacity Reservation Group.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAgentPoolWithCapacityReservationGroup(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2").withOsType(OSType.LINUX)
.withOrchestratorVersion("").withCapacityReservationGroupId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_crg.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"capacityReservationGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1",
"count": 3,
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_CRG.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_CRG.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithCapacityReservationGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
CapacityReservationGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"),
Count: to.Ptr[int32](3),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// CapacityReservationGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"),
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.9.6"),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.9.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_CRG.json
*/
async function createAgentPoolWithCapacityReservationGroup() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
capacityReservationGroupID:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1",
count: 3,
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"capacityReservationGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"capacityReservationGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/CapacityReservationGroups/crg1"
}
}
Create Agent Pool with Dedicated Host Group
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"hostGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_DedicatedHostGroup.json
*/
/**
* Sample code: Create Agent Pool with Dedicated Host Group.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithDedicatedHostGroup(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools()
.createOrUpdate("rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3)
.withVmSize("Standard_DS2_v2").withOsType(OSType.LINUX).withOrchestratorVersion("").withHostGroupId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_dedicated_host_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"hostGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1",
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_DedicatedHostGroup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_DedicatedHostGroup.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithDedicatedHostGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
HostGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// HostGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.19.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_DedicatedHostGroup.json
*/
async function createAgentPoolWithDedicatedHostGroup() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
hostGroupID:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1",
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.19.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"hostGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.19.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"hostGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"
}
}
Create Agent Pool with EncryptionAtHost enabled
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"enableEncryptionAtHost": true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_EnableEncryptionAtHost.json
*/
/**
* Sample code: Create Agent Pool with EncryptionAtHost enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAgentPoolWithEncryptionAtHostEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate(
"rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2")
.withOsType(OSType.LINUX).withOrchestratorVersion("").withEnableEncryptionAtHost(true),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_enable_encryption_at_host.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"enableEncryptionAtHost": True,
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableEncryptionAtHost.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableEncryptionAtHost.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithEncryptionAtHostEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
EnableEncryptionAtHost: to.Ptr(true),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.13"),
// EnableEncryptionAtHost: to.Ptr(true),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.17.13"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableEncryptionAtHost.json
*/
async function createAgentPoolWithEncryptionAtHostEnabled() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
enableEncryptionAtHost: true,
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.13",
"currentOrchestratorVersion": "1.17.13",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableEncryptionAtHost": true
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.13",
"currentOrchestratorVersion": "1.17.13",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableEncryptionAtHost": true
}
}
Create Agent Pool with Ephemeral OS Disk
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"osDiskType": "Ephemeral",
"osDiskSizeGB": 64
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSDiskType;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_Ephemeral.json
*/
/**
* Sample code: Create Agent Pool with Ephemeral OS Disk.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithEphemeralOSDisk(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2").withOsDiskSizeGB(64)
.withOsDiskType(OSDiskType.EPHEMERAL).withOsType(OSType.LINUX).withOrchestratorVersion(""),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_ephemeral.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"orchestratorVersion": "",
"osDiskSizeGB": 64,
"osDiskType": "Ephemeral",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Ephemeral.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Ephemeral.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithEphemeralOsDisk() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
OrchestratorVersion: to.Ptr(""),
OSDiskSizeGB: to.Ptr[int32](64),
OSDiskType: to.Ptr(armcontainerservice.OSDiskTypeEphemeral),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.8"),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.17.8"),
// OSDiskSizeGB: to.Ptr[int32](64),
// OSDiskType: to.Ptr(armcontainerservice.OSDiskTypeEphemeral),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Ephemeral.json
*/
async function createAgentPoolWithEphemeralOSDisk() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
orchestratorVersion: "",
osDiskSizeGB: 64,
osDiskType: "Ephemeral",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"osDiskType": "Ephemeral",
"osDiskSizeGB": 64
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"osDiskType": "Ephemeral",
"kubeletDiskType": "OS",
"osDiskSizeGB": 64
}
}
Create Agent Pool with FIPS enabled OS
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"enableFIPS": true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_EnableFIPS.json
*/
/**
* Sample code: Create Agent Pool with FIPS enabled OS.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithFIPSEnabledOS(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate(
"rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2")
.withOsType(OSType.LINUX).withOrchestratorVersion("").withEnableFips(true),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_enable_fips.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"enableFIPS": True,
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableFIPS.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableFIPS.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithFipsEnabledOs() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
EnableFIPS: to.Ptr(true),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.19.6"),
// EnableFIPS: to.Ptr(true),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.19.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableFIPS.json
*/
async function createAgentPoolWithFipsEnabledOS() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
enableFips: true,
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.19.6",
"currentOrchestratorVersion": "1.19.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableFIPS": true
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.19.6",
"currentOrchestratorVersion": "1.19.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableFIPS": true
}
}
Create Agent Pool with GPUMIG
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_ND96asr_v4",
"osType": "Linux",
"gpuInstanceProfile": "MIG2g",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 12345,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.GpuInstanceProfile;
import com.azure.resourcemanager.containerservice.models.KubeletConfig;
import com.azure.resourcemanager.containerservice.models.LinuxOSConfig;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.SysctlConfig;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_GPUMIG.json
*/
/**
* Sample code: Create Agent Pool with GPUMIG.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithGPUMIG(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools()
.createOrUpdate("rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3)
.withVmSize("Standard_ND96asr_v4").withOsType(OSType.LINUX).withOrchestratorVersion("")
.withKubeletConfig(new KubeletConfig().withCpuManagerPolicy("static").withCpuCfsQuota(true)
.withCpuCfsQuotaPeriod("200ms").withImageGcHighThreshold(90).withImageGcLowThreshold(70)
.withTopologyManagerPolicy("best-effort")
.withAllowedUnsafeSysctls(Arrays.asList("kernel.msg*", "net.core.somaxconn")).withFailSwapOn(false))
.withLinuxOSConfig(new LinuxOSConfig()
.withSysctls(new SysctlConfig().withNetCoreWmemDefault(12345).withNetIpv4TcpTwReuse(true)
.withNetIpv4IpLocalPortRange("20000 60000").withKernelThreadsMax(99999))
.withTransparentHugePageEnabled("always").withTransparentHugePageDefrag("madvise")
.withSwapFileSizeMB(1500))
.withGpuInstanceProfile(GpuInstanceProfile.MIG2G), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_gpumig.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"gpuInstanceProfile": "MIG2g",
"kubeletConfig": {
"allowedUnsafeSysctls": ["kernel.msg*", "net.core.somaxconn"],
"cpuCfsQuota": True,
"cpuCfsQuotaPeriod": "200ms",
"cpuManagerPolicy": "static",
"failSwapOn": False,
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
},
"linuxOSConfig": {
"swapFileSizeMB": 1500,
"sysctls": {
"kernelThreadsMax": 99999,
"netCoreWmemDefault": 12345,
"netIpv4IpLocalPortRange": "20000 60000",
"netIpv4TcpTwReuse": True,
},
"transparentHugePageDefrag": "madvise",
"transparentHugePageEnabled": "always",
},
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_ND96asr_v4",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_GPUMIG.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_GPUMIG.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithGpumig() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
GpuInstanceProfile: to.Ptr(armcontainerservice.GPUInstanceProfileMIG2G),
KubeletConfig: &armcontainerservice.KubeletConfig{
AllowedUnsafeSysctls: []*string{
to.Ptr("kernel.msg*"),
to.Ptr("net.core.somaxconn")},
CPUCfsQuota: to.Ptr(true),
CPUCfsQuotaPeriod: to.Ptr("200ms"),
CPUManagerPolicy: to.Ptr("static"),
FailSwapOn: to.Ptr(false),
ImageGcHighThreshold: to.Ptr[int32](90),
ImageGcLowThreshold: to.Ptr[int32](70),
TopologyManagerPolicy: to.Ptr("best-effort"),
},
LinuxOSConfig: &armcontainerservice.LinuxOSConfig{
SwapFileSizeMB: to.Ptr[int32](1500),
Sysctls: &armcontainerservice.SysctlConfig{
KernelThreadsMax: to.Ptr[int32](99999),
NetCoreWmemDefault: to.Ptr[int32](12345),
NetIPv4IPLocalPortRange: to.Ptr("20000 60000"),
NetIPv4TCPTwReuse: to.Ptr(true),
},
TransparentHugePageDefrag: to.Ptr("madvise"),
TransparentHugePageEnabled: to.Ptr("always"),
},
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_ND96asr_v4"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.8"),
// GpuInstanceProfile: to.Ptr(armcontainerservice.GPUInstanceProfileMIG2G),
// KubeletConfig: &armcontainerservice.KubeletConfig{
// AllowedUnsafeSysctls: []*string{
// to.Ptr("kernel.msg*"),
// to.Ptr("net.core.somaxconn")},
// CPUCfsQuota: to.Ptr(true),
// CPUCfsQuotaPeriod: to.Ptr("200ms"),
// CPUManagerPolicy: to.Ptr("static"),
// FailSwapOn: to.Ptr(false),
// ImageGcHighThreshold: to.Ptr[int32](90),
// ImageGcLowThreshold: to.Ptr[int32](70),
// TopologyManagerPolicy: to.Ptr("best-effort"),
// },
// LinuxOSConfig: &armcontainerservice.LinuxOSConfig{
// SwapFileSizeMB: to.Ptr[int32](1500),
// Sysctls: &armcontainerservice.SysctlConfig{
// KernelThreadsMax: to.Ptr[int32](99999),
// NetCoreWmemDefault: to.Ptr[int32](12345),
// NetIPv4IPLocalPortRange: to.Ptr("20000 60000"),
// NetIPv4TCPTwReuse: to.Ptr(true),
// },
// TransparentHugePageDefrag: to.Ptr("madvise"),
// TransparentHugePageEnabled: to.Ptr("always"),
// },
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.17.8"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_ND96asr_v4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_GPUMIG.json
*/
async function createAgentPoolWithGpumig() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
gpuInstanceProfile: "MIG2g",
kubeletConfig: {
allowedUnsafeSysctls: ["kernel.msg*", "net.core.somaxconn"],
cpuCfsQuota: true,
cpuCfsQuotaPeriod: "200ms",
cpuManagerPolicy: "static",
failSwapOn: false,
imageGcHighThreshold: 90,
imageGcLowThreshold: 70,
topologyManagerPolicy: "best-effort",
},
linuxOSConfig: {
swapFileSizeMB: 1500,
sysctls: {
kernelThreadsMax: 99999,
netCoreWmemDefault: 12345,
netIpv4IpLocalPortRange: "20000 60000",
netIpv4TcpTwReuse: true,
},
transparentHugePageDefrag: "madvise",
transparentHugePageEnabled: "always",
},
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_ND96asr_v4",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_ND96asr_v4",
"maxPods": 110,
"osType": "Linux",
"gpuInstanceProfile": "MIG2g",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 12345,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_ND96asr_v4",
"maxPods": 110,
"osType": "Linux",
"gpuInstanceProfile": "MIG2g",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false,
"podMaxPids": 100
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 65536,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
Create Agent Pool with Krustlet and the WASI runtime
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"osDiskSizeGB": 64,
"mode": "User",
"workloadRuntime": "WasmWasi"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.WorkloadRuntime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_WasmWasi.json
*/
/**
* Sample code: Create Agent Pool with Krustlet and the WASI runtime.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAgentPoolWithKrustletAndTheWASIRuntime(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2").withOsDiskSizeGB(64)
.withWorkloadRuntime(WorkloadRuntime.WASM_WASI).withOsType(OSType.LINUX).withMode(AgentPoolMode.USER)
.withOrchestratorVersion(""),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_wasm_wasi.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"mode": "User",
"orchestratorVersion": "",
"osDiskSizeGB": 64,
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
"workloadRuntime": "WasmWasi",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WasmWasi.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WasmWasi.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithKrustletAndTheWasiRuntime() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
Mode: to.Ptr(armcontainerservice.AgentPoolModeUser),
OrchestratorVersion: to.Ptr(""),
OSDiskSizeGB: to.Ptr[int32](64),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
WorkloadRuntime: to.Ptr(armcontainerservice.WorkloadRuntimeWasmWasi),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.8"),
// MaxPods: to.Ptr[int32](110),
// Mode: to.Ptr(armcontainerservice.AgentPoolModeUser),
// OrchestratorVersion: to.Ptr("1.17.8"),
// OSDiskSizeGB: to.Ptr[int32](64),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// WorkloadRuntime: to.Ptr(armcontainerservice.WorkloadRuntimeWasmWasi),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WasmWasi.json
*/
async function createAgentPoolWithKrustletAndTheWasiRuntime() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
mode: "User",
orchestratorVersion: "",
osDiskSizeGB: 64,
osType: "Linux",
vmSize: "Standard_DS2_v2",
workloadRuntime: "WasmWasi",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"osDiskSizeGB": 64,
"mode": "User",
"workloadRuntime": "WasmWasi"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"osDiskSizeGB": 64,
"mode": "User",
"workloadRuntime": "WasmWasi"
}
}
Create Agent Pool with KubeletConfig and LinuxOSConfig
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 12345,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.KubeletConfig;
import com.azure.resourcemanager.containerservice.models.LinuxOSConfig;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.SysctlConfig;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_CustomNodeConfig.json
*/
/**
* Sample code: Create Agent Pool with KubeletConfig and LinuxOSConfig.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createAgentPoolWithKubeletConfigAndLinuxOSConfig(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools()
.createOrUpdate("rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3)
.withVmSize("Standard_DS2_v2").withOsType(OSType.LINUX).withOrchestratorVersion("")
.withKubeletConfig(new KubeletConfig().withCpuManagerPolicy("static").withCpuCfsQuota(true)
.withCpuCfsQuotaPeriod("200ms").withImageGcHighThreshold(90).withImageGcLowThreshold(70)
.withTopologyManagerPolicy("best-effort")
.withAllowedUnsafeSysctls(Arrays.asList("kernel.msg*", "net.core.somaxconn")).withFailSwapOn(false))
.withLinuxOSConfig(new LinuxOSConfig()
.withSysctls(new SysctlConfig().withNetCoreWmemDefault(12345).withNetIpv4TcpTwReuse(true)
.withNetIpv4IpLocalPortRange("20000 60000").withKernelThreadsMax(99999))
.withTransparentHugePageEnabled("always").withTransparentHugePageDefrag("madvise")
.withSwapFileSizeMB(1500)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_custom_node_config.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"kubeletConfig": {
"allowedUnsafeSysctls": ["kernel.msg*", "net.core.somaxconn"],
"cpuCfsQuota": True,
"cpuCfsQuotaPeriod": "200ms",
"cpuManagerPolicy": "static",
"failSwapOn": False,
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
},
"linuxOSConfig": {
"swapFileSizeMB": 1500,
"sysctls": {
"kernelThreadsMax": 99999,
"netCoreWmemDefault": 12345,
"netIpv4IpLocalPortRange": "20000 60000",
"netIpv4TcpTwReuse": True,
},
"transparentHugePageDefrag": "madvise",
"transparentHugePageEnabled": "always",
},
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_CustomNodeConfig.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_CustomNodeConfig.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithKubeletConfigAndLinuxOsConfig() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
KubeletConfig: &armcontainerservice.KubeletConfig{
AllowedUnsafeSysctls: []*string{
to.Ptr("kernel.msg*"),
to.Ptr("net.core.somaxconn")},
CPUCfsQuota: to.Ptr(true),
CPUCfsQuotaPeriod: to.Ptr("200ms"),
CPUManagerPolicy: to.Ptr("static"),
FailSwapOn: to.Ptr(false),
ImageGcHighThreshold: to.Ptr[int32](90),
ImageGcLowThreshold: to.Ptr[int32](70),
TopologyManagerPolicy: to.Ptr("best-effort"),
},
LinuxOSConfig: &armcontainerservice.LinuxOSConfig{
SwapFileSizeMB: to.Ptr[int32](1500),
Sysctls: &armcontainerservice.SysctlConfig{
KernelThreadsMax: to.Ptr[int32](99999),
NetCoreWmemDefault: to.Ptr[int32](12345),
NetIPv4IPLocalPortRange: to.Ptr("20000 60000"),
NetIPv4TCPTwReuse: to.Ptr(true),
},
TransparentHugePageDefrag: to.Ptr("madvise"),
TransparentHugePageEnabled: to.Ptr("always"),
},
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.8"),
// KubeletConfig: &armcontainerservice.KubeletConfig{
// AllowedUnsafeSysctls: []*string{
// to.Ptr("kernel.msg*"),
// to.Ptr("net.core.somaxconn")},
// CPUCfsQuota: to.Ptr(true),
// CPUCfsQuotaPeriod: to.Ptr("200ms"),
// CPUManagerPolicy: to.Ptr("static"),
// FailSwapOn: to.Ptr(false),
// ImageGcHighThreshold: to.Ptr[int32](90),
// ImageGcLowThreshold: to.Ptr[int32](70),
// TopologyManagerPolicy: to.Ptr("best-effort"),
// },
// LinuxOSConfig: &armcontainerservice.LinuxOSConfig{
// SwapFileSizeMB: to.Ptr[int32](1500),
// Sysctls: &armcontainerservice.SysctlConfig{
// KernelThreadsMax: to.Ptr[int32](99999),
// NetCoreWmemDefault: to.Ptr[int32](12345),
// NetIPv4IPLocalPortRange: to.Ptr("20000 60000"),
// NetIPv4TCPTwReuse: to.Ptr(true),
// },
// TransparentHugePageDefrag: to.Ptr("madvise"),
// TransparentHugePageEnabled: to.Ptr("always"),
// },
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.17.8"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_CustomNodeConfig.json
*/
async function createAgentPoolWithKubeletConfigAndLinuxOSConfig() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
kubeletConfig: {
allowedUnsafeSysctls: ["kernel.msg*", "net.core.somaxconn"],
cpuCfsQuota: true,
cpuCfsQuotaPeriod: "200ms",
cpuManagerPolicy: "static",
failSwapOn: false,
imageGcHighThreshold: 90,
imageGcLowThreshold: 70,
topologyManagerPolicy: "best-effort",
},
linuxOSConfig: {
swapFileSizeMB: 1500,
sysctls: {
kernelThreadsMax: 99999,
netCoreWmemDefault: 12345,
netIpv4IpLocalPortRange: "20000 60000",
netIpv4TcpTwReuse: true,
},
transparentHugePageDefrag: "madvise",
transparentHugePageEnabled: "always",
},
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 12345,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false,
"podMaxPids": 100
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 65536,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
Create Agent Pool with OSSKU
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"osSKU": "AzureLinux",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 12345,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.KubeletConfig;
import com.azure.resourcemanager.containerservice.models.LinuxOSConfig;
import com.azure.resourcemanager.containerservice.models.OSSku;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.SysctlConfig;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_OSSKU.json
*/
/**
* Sample code: Create Agent Pool with OSSKU.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithOSSKU(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2").withOsType(OSType.LINUX)
.withOsSku(OSSku.AZURE_LINUX).withOrchestratorVersion("")
.withKubeletConfig(new KubeletConfig().withCpuManagerPolicy("static").withCpuCfsQuota(true)
.withCpuCfsQuotaPeriod("200ms").withImageGcHighThreshold(90).withImageGcLowThreshold(70)
.withTopologyManagerPolicy("best-effort")
.withAllowedUnsafeSysctls(Arrays.asList("kernel.msg*", "net.core.somaxconn")).withFailSwapOn(false))
.withLinuxOSConfig(new LinuxOSConfig()
.withSysctls(new SysctlConfig().withNetCoreWmemDefault(12345).withNetIpv4TcpTwReuse(true)
.withNetIpv4IpLocalPortRange("20000 60000").withKernelThreadsMax(99999))
.withTransparentHugePageEnabled("always").withTransparentHugePageDefrag("madvise")
.withSwapFileSizeMB(1500)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_ossku.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"kubeletConfig": {
"allowedUnsafeSysctls": ["kernel.msg*", "net.core.somaxconn"],
"cpuCfsQuota": True,
"cpuCfsQuotaPeriod": "200ms",
"cpuManagerPolicy": "static",
"failSwapOn": False,
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
},
"linuxOSConfig": {
"swapFileSizeMB": 1500,
"sysctls": {
"kernelThreadsMax": 99999,
"netCoreWmemDefault": 12345,
"netIpv4IpLocalPortRange": "20000 60000",
"netIpv4TcpTwReuse": True,
},
"transparentHugePageDefrag": "madvise",
"transparentHugePageEnabled": "always",
},
"orchestratorVersion": "",
"osSKU": "AzureLinux",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_OSSKU.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_OSSKU.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithOssku() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
KubeletConfig: &armcontainerservice.KubeletConfig{
AllowedUnsafeSysctls: []*string{
to.Ptr("kernel.msg*"),
to.Ptr("net.core.somaxconn")},
CPUCfsQuota: to.Ptr(true),
CPUCfsQuotaPeriod: to.Ptr("200ms"),
CPUManagerPolicy: to.Ptr("static"),
FailSwapOn: to.Ptr(false),
ImageGcHighThreshold: to.Ptr[int32](90),
ImageGcLowThreshold: to.Ptr[int32](70),
TopologyManagerPolicy: to.Ptr("best-effort"),
},
LinuxOSConfig: &armcontainerservice.LinuxOSConfig{
SwapFileSizeMB: to.Ptr[int32](1500),
Sysctls: &armcontainerservice.SysctlConfig{
KernelThreadsMax: to.Ptr[int32](99999),
NetCoreWmemDefault: to.Ptr[int32](12345),
NetIPv4IPLocalPortRange: to.Ptr("20000 60000"),
NetIPv4TCPTwReuse: to.Ptr(true),
},
TransparentHugePageDefrag: to.Ptr("madvise"),
TransparentHugePageEnabled: to.Ptr("always"),
},
OrchestratorVersion: to.Ptr(""),
OSSKU: to.Ptr(armcontainerservice.OSSKUAzureLinux),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.8"),
// KubeletConfig: &armcontainerservice.KubeletConfig{
// AllowedUnsafeSysctls: []*string{
// to.Ptr("kernel.msg*"),
// to.Ptr("net.core.somaxconn")},
// CPUCfsQuota: to.Ptr(true),
// CPUCfsQuotaPeriod: to.Ptr("200ms"),
// CPUManagerPolicy: to.Ptr("static"),
// FailSwapOn: to.Ptr(false),
// ImageGcHighThreshold: to.Ptr[int32](90),
// ImageGcLowThreshold: to.Ptr[int32](70),
// TopologyManagerPolicy: to.Ptr("best-effort"),
// },
// LinuxOSConfig: &armcontainerservice.LinuxOSConfig{
// SwapFileSizeMB: to.Ptr[int32](1500),
// Sysctls: &armcontainerservice.SysctlConfig{
// KernelThreadsMax: to.Ptr[int32](99999),
// NetCoreWmemDefault: to.Ptr[int32](12345),
// NetIPv4IPLocalPortRange: to.Ptr("20000 60000"),
// NetIPv4TCPTwReuse: to.Ptr(true),
// },
// TransparentHugePageDefrag: to.Ptr("madvise"),
// TransparentHugePageEnabled: to.Ptr("always"),
// },
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.17.8"),
// OSSKU: to.Ptr(armcontainerservice.OSSKUAzureLinux),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_OSSKU.json
*/
async function createAgentPoolWithOssku() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
kubeletConfig: {
allowedUnsafeSysctls: ["kernel.msg*", "net.core.somaxconn"],
cpuCfsQuota: true,
cpuCfsQuotaPeriod: "200ms",
cpuManagerPolicy: "static",
failSwapOn: false,
imageGcHighThreshold: 90,
imageGcLowThreshold: 70,
topologyManagerPolicy: "best-effort",
},
linuxOSConfig: {
swapFileSizeMB: 1500,
sysctls: {
kernelThreadsMax: 99999,
netCoreWmemDefault: 12345,
netIpv4IpLocalPortRange: "20000 60000",
netIpv4TcpTwReuse: true,
},
transparentHugePageDefrag: "madvise",
transparentHugePageEnabled: "always",
},
orchestratorVersion: "",
osSKU: "AzureLinux",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"osSKU": "AzureLinux",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 12345,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.8",
"currentOrchestratorVersion": "1.17.8",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"osSKU": "AzureLinux",
"kubeletConfig": {
"cpuManagerPolicy": "static",
"cpuCfsQuota": true,
"cpuCfsQuotaPeriod": "200ms",
"imageGcHighThreshold": 90,
"imageGcLowThreshold": 70,
"topologyManagerPolicy": "best-effort",
"allowedUnsafeSysctls": [
"kernel.msg*",
"net.core.somaxconn"
],
"failSwapOn": false,
"podMaxPids": 100
},
"linuxOSConfig": {
"sysctls": {
"netCoreWmemDefault": 65536,
"netIpv4TcpTwReuse": true,
"netIpv4IpLocalPortRange": "20000 60000",
"kernelThreadsMax": 99999
},
"transparentHugePageEnabled": "always",
"transparentHugePageDefrag": "madvise",
"swapFileSizeMB": 1500
}
}
}
Create Agent Pool with PPG
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"proximityPlacementGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_PPG.json
*/
/**
* Sample code: Create Agent Pool with PPG.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithPPG(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2").withOsType(OSType.LINUX)
.withOrchestratorVersion("").withProximityPlacementGroupId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_ppg.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"orchestratorVersion": "",
"osType": "Linux",
"proximityPlacementGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_PPG.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_PPG.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithPpg() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ProximityPlacementGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.9.6"),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.9.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// ProximityPlacementGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_PPG.json
*/
async function createAgentPoolWithPpg() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
orchestratorVersion: "",
osType: "Linux",
proximityPlacementGroupID:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"proximityPlacementGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"proximityPlacementGroupID": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"
}
}
Create Agent Pool with UltraSSD enabled
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS2_v2",
"osType": "Linux",
"enableUltraSSD": true
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_EnableUltraSSD.json
*/
/**
* Sample code: Create Agent Pool with UltraSSD enabled.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithUltraSSDEnabled(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate(
"rg1", "clustername1", "agentpool1", new AgentPoolInner().withCount(3).withVmSize("Standard_DS2_v2")
.withOsType(OSType.LINUX).withOrchestratorVersion("").withEnableUltraSsd(true),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_enable_ultra_ssd.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"enableUltraSSD": True,
"orchestratorVersion": "",
"osType": "Linux",
"vmSize": "Standard_DS2_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableUltraSSD.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableUltraSSD.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithUltraSsdEnabled() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
EnableUltraSSD: to.Ptr(true),
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
VMSize: to.Ptr("Standard_DS2_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.17.13"),
// EnableUltraSSD: to.Ptr(true),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.17.13"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_DS2_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_EnableUltraSSD.json
*/
async function createAgentPoolWithUltraSsdEnabled() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
enableUltraSSD: true,
orchestratorVersion: "",
osType: "Linux",
vmSize: "Standard_DS2_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.17.13",
"currentOrchestratorVersion": "1.17.13",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableUltraSSD": true
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.17.13",
"currentOrchestratorVersion": "1.17.13",
"count": 3,
"vmSize": "Standard_DS2_v2",
"maxPods": 110,
"osType": "Linux",
"enableUltraSSD": true
}
}
Create Agent Pool with Windows OSSKU
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "1.23.3",
"count": 3,
"vmSize": "Standard_D4s_v3",
"osType": "Windows",
"osSKU": "Windows2022"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSSku;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_WindowsOSSKU.json
*/
/**
* Sample code: Create Agent Pool with Windows OSSKU.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createAgentPoolWithWindowsOSSKU(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate(
"rg1", "clustername1", "wnp2", new AgentPoolInner().withCount(3).withVmSize("Standard_D4s_v3")
.withOsType(OSType.WINDOWS).withOsSku(OSSku.WINDOWS2022).withOrchestratorVersion("1.23.3"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_windows_ossku.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="wnp2",
parameters={
"properties": {
"count": 3,
"orchestratorVersion": "1.23.3",
"osSKU": "Windows2022",
"osType": "Windows",
"vmSize": "Standard_D4s_v3",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WindowsOSSKU.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WindowsOSSKU.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createAgentPoolWithWindowsOssku() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "wnp2", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
OrchestratorVersion: to.Ptr("1.23.3"),
OSSKU: to.Ptr(armcontainerservice.OSSKUWindows2022),
OSType: to.Ptr(armcontainerservice.OSTypeWindows),
VMSize: to.Ptr("Standard_D4s_v3"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("wnp2"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.23.3"),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.23.3"),
// OSSKU: to.Ptr(armcontainerservice.OSSKUWindows2022),
// OSType: to.Ptr(armcontainerservice.OSTypeWindows),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_D4s_v3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WindowsOSSKU.json
*/
async function createAgentPoolWithWindowsOssku() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "wnp2";
const parameters = {
count: 3,
orchestratorVersion: "1.23.3",
osSKU: "Windows2022",
osType: "Windows",
vmSize: "Standard_D4s_v3",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "wnp2",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.23.3",
"currentOrchestratorVersion": "1.23.3",
"count": 3,
"vmSize": "Standard_D4s_v3",
"maxPods": 110,
"osType": "Windows",
"osSKU": "Windows2022"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "wnp2",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.23.3",
"currentOrchestratorVersion": "1.23.3",
"count": 3,
"vmSize": "Standard_D4s_v3",
"maxPods": 110,
"osType": "Windows",
"osSKU": "Windows2022"
}
}
Create Spot Agent Pool
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS1_v2",
"osType": "Linux",
"tags": {
"name1": "val1"
},
"nodeLabels": {
"key1": "val1"
},
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.ScaleSetEvictionPolicy;
import com.azure.resourcemanager.containerservice.models.ScaleSetPriority;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_Spot.json
*/
/**
* Sample code: Create Spot Agent Pool.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createSpotAgentPool(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS1_v2").withOsType(OSType.LINUX)
.withOrchestratorVersion("").withScaleSetPriority(ScaleSetPriority.SPOT)
.withScaleSetEvictionPolicy(ScaleSetEvictionPolicy.DELETE).withTags(mapOf("name1", "val1"))
.withNodeLabels(mapOf("key1", "fakeTokenPlaceholder"))
.withNodeTaints(Arrays.asList("Key1=Value1:NoSchedule")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_spot.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"nodeLabels": {"key1": "val1"},
"nodeTaints": ["Key1=Value1:NoSchedule"],
"orchestratorVersion": "",
"osType": "Linux",
"scaleSetEvictionPolicy": "Delete",
"scaleSetPriority": "Spot",
"tags": {"name1": "val1"},
"vmSize": "Standard_DS1_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Spot.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Spot.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createSpotAgentPool() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
NodeLabels: map[string]*string{
"key1": to.Ptr("val1"),
},
NodeTaints: []*string{
to.Ptr("Key1=Value1:NoSchedule")},
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ScaleSetEvictionPolicy: to.Ptr(armcontainerservice.ScaleSetEvictionPolicyDelete),
ScaleSetPriority: to.Ptr(armcontainerservice.ScaleSetPrioritySpot),
Tags: map[string]*string{
"name1": to.Ptr("val1"),
},
VMSize: to.Ptr("Standard_DS1_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.9.6"),
// MaxPods: to.Ptr[int32](110),
// NodeLabels: map[string]*string{
// "key1": to.Ptr("val1"),
// },
// NodeTaints: []*string{
// to.Ptr("Key1=Value1:NoSchedule")},
// OrchestratorVersion: to.Ptr("1.9.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// ScaleSetEvictionPolicy: to.Ptr(armcontainerservice.ScaleSetEvictionPolicyDelete),
// ScaleSetPriority: to.Ptr(armcontainerservice.ScaleSetPrioritySpot),
// SpotMaxPrice: to.Ptr[float32](-1),
// Tags: map[string]*string{
// "name1": to.Ptr("val1"),
// },
// VMSize: to.Ptr("Standard_DS1_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Spot.json
*/
async function createSpotAgentPool() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
nodeLabels: { key1: "val1" },
nodeTaints: ["Key1=Value1:NoSchedule"],
orchestratorVersion: "",
osType: "Linux",
scaleSetEvictionPolicy: "Delete",
scaleSetPriority: "Spot",
tags: { name1: "val1" },
vmSize: "Standard_DS1_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS1_v2",
"maxPods": 110,
"osType": "Linux",
"tags": {
"name1": "val1"
},
"nodeLabels": {
"key1": "val1"
},
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete",
"spotMaxPrice": -1
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS1_v2",
"maxPods": 110,
"osType": "Linux",
"tags": {
"name1": "val1"
},
"nodeLabels": {
"key1": "val1"
},
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete",
"spotMaxPrice": -1
}
}
Create Windows Agent Pool with disabling OutboundNAT
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "1.23.8",
"count": 3,
"vmSize": "Standard_D4s_v3",
"osType": "Windows",
"osSKU": "Windows2022",
"windowsProfile": {
"disableOutboundNat": true
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolWindowsProfile;
import com.azure.resourcemanager.containerservice.models.OSSku;
import com.azure.resourcemanager.containerservice.models.OSType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_WindowsDisableOutboundNAT.json
*/
/**
* Sample code: Create Windows Agent Pool with disabling OutboundNAT.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createWindowsAgentPoolWithDisablingOutboundNAT(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"wnp2",
new AgentPoolInner().withCount(3).withVmSize("Standard_D4s_v3").withOsType(OSType.WINDOWS)
.withOsSku(OSSku.WINDOWS2022).withOrchestratorVersion("1.23.8").withWindowsProfile(
new AgentPoolWindowsProfile().withDisableOutboundNat(true)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_windows_disable_outbound_nat.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="wnp2",
parameters={
"properties": {
"count": 3,
"orchestratorVersion": "1.23.8",
"osSKU": "Windows2022",
"osType": "Windows",
"vmSize": "Standard_D4s_v3",
"windowsProfile": {"disableOutboundNat": True},
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WindowsDisableOutboundNAT.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WindowsDisableOutboundNAT.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createWindowsAgentPoolWithDisablingOutboundNat() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "wnp2", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
OrchestratorVersion: to.Ptr("1.23.8"),
OSSKU: to.Ptr(armcontainerservice.OSSKUWindows2022),
OSType: to.Ptr(armcontainerservice.OSTypeWindows),
VMSize: to.Ptr("Standard_D4s_v3"),
WindowsProfile: &armcontainerservice.AgentPoolWindowsProfile{
DisableOutboundNat: to.Ptr(true),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("wnp2"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.23.8"),
// MaxPods: to.Ptr[int32](110),
// OrchestratorVersion: to.Ptr("1.23.8"),
// OSSKU: to.Ptr(armcontainerservice.OSSKUWindows2022),
// OSType: to.Ptr(armcontainerservice.OSTypeWindows),
// ProvisioningState: to.Ptr("Succeeded"),
// VMSize: to.Ptr("Standard_D4s_v3"),
// WindowsProfile: &armcontainerservice.AgentPoolWindowsProfile{
// DisableOutboundNat: to.Ptr(true),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_WindowsDisableOutboundNAT.json
*/
async function createWindowsAgentPoolWithDisablingOutboundNat() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "wnp2";
const parameters = {
count: 3,
orchestratorVersion: "1.23.8",
osSKU: "Windows2022",
osType: "Windows",
vmSize: "Standard_D4s_v3",
windowsProfile: { disableOutboundNat: true },
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "wnp2",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.23.8",
"currentOrchestratorVersion": "1.23.8",
"count": 3,
"vmSize": "Standard_D4s_v3",
"maxPods": 110,
"osType": "Windows",
"osSKU": "Windows2022",
"windowsProfile": {
"disableOutboundNat": true
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/wnp2",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "wnp2",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.23.8",
"currentOrchestratorVersion": "1.23.8",
"count": 3,
"vmSize": "Standard_D4s_v3",
"maxPods": 110,
"osType": "Windows",
"osSKU": "Windows2022",
"windowsProfile": {
"disableOutboundNat": true
}
}
}
Create/Update Agent Pool
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"vmSize": "Standard_DS1_v2",
"osType": "Linux",
"tags": {
"name1": "val1"
},
"nodeLabels": {
"key1": "val1"
},
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete",
"mode": "User"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.AgentPoolMode;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.ScaleSetEvictionPolicy;
import com.azure.resourcemanager.containerservice.models.ScaleSetPriority;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPoolsCreate_Update.json
*/
/**
* Sample code: Create/Update Agent Pool.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createUpdateAgentPool(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS1_v2").withOsType(OSType.LINUX)
.withMode(AgentPoolMode.USER).withOrchestratorVersion("").withScaleSetPriority(ScaleSetPriority.SPOT)
.withScaleSetEvictionPolicy(ScaleSetEvictionPolicy.DELETE).withTags(mapOf("name1", "val1"))
.withNodeLabels(mapOf("key1", "fakeTokenPlaceholder"))
.withNodeTaints(Arrays.asList("Key1=Value1:NoSchedule")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_create_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"mode": "User",
"nodeLabels": {"key1": "val1"},
"nodeTaints": ["Key1=Value1:NoSchedule"],
"orchestratorVersion": "",
"osType": "Linux",
"scaleSetEvictionPolicy": "Delete",
"scaleSetPriority": "Spot",
"tags": {"name1": "val1"},
"vmSize": "Standard_DS1_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Update.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Update.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_createUpdateAgentPool() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
Mode: to.Ptr(armcontainerservice.AgentPoolModeUser),
NodeLabels: map[string]*string{
"key1": to.Ptr("val1"),
},
NodeTaints: []*string{
to.Ptr("Key1=Value1:NoSchedule")},
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ScaleSetEvictionPolicy: to.Ptr(armcontainerservice.ScaleSetEvictionPolicyDelete),
ScaleSetPriority: to.Ptr(armcontainerservice.ScaleSetPrioritySpot),
Tags: map[string]*string{
"name1": to.Ptr("val1"),
},
VMSize: to.Ptr("Standard_DS1_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.9.6"),
// MaxPods: to.Ptr[int32](110),
// Mode: to.Ptr(armcontainerservice.AgentPoolModeUser),
// NodeImageVersion: to.Ptr("AKSUbuntu:1604:2020.03.11"),
// NodeLabels: map[string]*string{
// "key1": to.Ptr("val1"),
// },
// NodeTaints: []*string{
// to.Ptr("Key1=Value1:NoSchedule")},
// OrchestratorVersion: to.Ptr("1.9.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// ScaleSetEvictionPolicy: to.Ptr(armcontainerservice.ScaleSetEvictionPolicyDelete),
// ScaleSetPriority: to.Ptr(armcontainerservice.ScaleSetPrioritySpot),
// Tags: map[string]*string{
// "name1": to.Ptr("val1"),
// },
// VMSize: to.Ptr("Standard_DS1_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPoolsCreate_Update.json
*/
async function createOrUpdateAgentPool() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
mode: "User",
nodeLabels: { key1: "val1" },
nodeTaints: ["Key1=Value1:NoSchedule"],
orchestratorVersion: "",
osType: "Linux",
scaleSetEvictionPolicy: "Delete",
scaleSetPriority: "Spot",
tags: { name1: "val1" },
vmSize: "Standard_DS1_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS1_v2",
"maxPods": 110,
"osType": "Linux",
"tags": {
"name1": "val1"
},
"nodeLabels": {
"key1": "val1"
},
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete",
"mode": "User",
"nodeImageVersion": "AKSUbuntu:1604:2020.03.11"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Creating",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"vmSize": "Standard_DS1_v2",
"maxPods": 110,
"osType": "Linux",
"tags": {
"name1": "val1"
},
"nodeLabels": {
"key1": "val1"
},
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete",
"mode": "User"
}
}
Start Agent Pool
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"powerState": {
"code": "Running"
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.Code;
import com.azure.resourcemanager.containerservice.models.PowerState;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPools_Start.json
*/
/**
* Sample code: Start Agent Pool.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void startAgentPool(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1", new AgentPoolInner().withPowerState(new PowerState().withCode(Code.RUNNING)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_start.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={"properties": {"powerState": {"code": "Running"}}},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Start.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Start.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_startAgentPool() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
PowerState: &armcontainerservice.PowerState{
Code: to.Ptr(armcontainerservice.CodeRunning),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](50),
// EnableAutoScaling: to.Ptr(true),
// MaxCount: to.Ptr[int32](55),
// MinCount: to.Ptr[int32](3),
// PowerState: &armcontainerservice.PowerState{
// Code: to.Ptr(armcontainerservice.CodeRunning),
// },
// ProvisioningState: to.Ptr("Succeeded"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Start.json
*/
async function startAgentPool() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = { powerState: { code: "Running" } };
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Starting",
"count": 50,
"enableAutoScaling": true,
"minCount": 3,
"maxCount": 55,
"powerState": {
"code": "Running"
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Starting",
"count": 50,
"enableAutoScaling": true,
"minCount": 3,
"maxCount": 55,
"powerState": {
"code": "Running"
}
}
}
Stop Agent Pool
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"powerState": {
"code": "Stopped"
}
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.Code;
import com.azure.resourcemanager.containerservice.models.PowerState;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPools_Stop.json
*/
/**
* Sample code: Stop Agent Pool.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void stopAgentPool(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1", new AgentPoolInner().withPowerState(new PowerState().withCode(Code.STOPPED)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_stop.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={"properties": {"powerState": {"code": "Stopped"}}},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Stop.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Stop.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_stopAgentPool() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
PowerState: &armcontainerservice.PowerState{
Code: to.Ptr(armcontainerservice.CodeStopped),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](0),
// EnableAutoScaling: to.Ptr(false),
// PowerState: &armcontainerservice.PowerState{
// Code: to.Ptr(armcontainerservice.CodeStopped),
// },
// ProvisioningState: to.Ptr("Succeeded"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Stop.json
*/
async function stopAgentPool() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = { powerState: { code: "Stopped" } };
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Stopping",
"count": 0,
"enableAutoScaling": false,
"minCount": null,
"maxCount": null,
"powerState": {
"code": "Stopped"
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Stopping",
"count": 0,
"enableAutoScaling": false,
"minCount": null,
"maxCount": null,
"powerState": {
"code": "Stopped"
}
}
}
Update Agent Pool
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1?api-version=2024-08-01
{
"properties": {
"orchestratorVersion": "",
"count": 3,
"enableAutoScaling": true,
"minCount": 2,
"maxCount": 2,
"vmSize": "Standard_DS1_v2",
"osType": "Linux",
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete"
}
}
import com.azure.resourcemanager.containerservice.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.ScaleSetEvictionPolicy;
import com.azure.resourcemanager.containerservice.models.ScaleSetPriority;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for AgentPools CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/
* AgentPools_Update.json
*/
/**
* Sample code: Update Agent Pool.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void updateAgentPool(com.azure.resourcemanager.AzureResourceManager azure) {
azure.kubernetesClusters().manager().serviceClient().getAgentPools().createOrUpdate("rg1", "clustername1",
"agentpool1",
new AgentPoolInner().withCount(3).withVmSize("Standard_DS1_v2").withOsType(OSType.LINUX).withMaxCount(2)
.withMinCount(2).withEnableAutoScaling(true).withOrchestratorVersion("")
.withScaleSetPriority(ScaleSetPriority.SPOT).withScaleSetEvictionPolicy(ScaleSetEvictionPolicy.DELETE)
.withNodeTaints(Arrays.asList("Key1=Value1:NoSchedule")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerservice import ContainerServiceClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerservice
# USAGE
python agent_pools_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerServiceClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.agent_pools.begin_create_or_update(
resource_group_name="rg1",
resource_name="clustername1",
agent_pool_name="agentpool1",
parameters={
"properties": {
"count": 3,
"enableAutoScaling": True,
"maxCount": 2,
"minCount": 2,
"nodeTaints": ["Key1=Value1:NoSchedule"],
"orchestratorVersion": "",
"osType": "Linux",
"scaleSetEvictionPolicy": "Delete",
"scaleSetPriority": "Spot",
"vmSize": "Standard_DS1_v2",
}
},
).result()
print(response)
# x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Update.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Update.json
func ExampleAgentPoolsClient_BeginCreateOrUpdate_updateAgentPool() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewAgentPoolsClient().BeginCreateOrUpdate(ctx, "rg1", "clustername1", "agentpool1", armcontainerservice.AgentPool{
Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
Count: to.Ptr[int32](3),
EnableAutoScaling: to.Ptr(true),
MaxCount: to.Ptr[int32](2),
MinCount: to.Ptr[int32](2),
NodeTaints: []*string{
to.Ptr("Key1=Value1:NoSchedule")},
OrchestratorVersion: to.Ptr(""),
OSType: to.Ptr(armcontainerservice.OSTypeLinux),
ScaleSetEvictionPolicy: to.Ptr(armcontainerservice.ScaleSetEvictionPolicyDelete),
ScaleSetPriority: to.Ptr(armcontainerservice.ScaleSetPrioritySpot),
VMSize: to.Ptr("Standard_DS1_v2"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AgentPool = armcontainerservice.AgentPool{
// Name: to.Ptr("agentpool1"),
// Type: to.Ptr("Microsoft.ContainerService/managedClusters/agentPools"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1"),
// Properties: &armcontainerservice.ManagedClusterAgentPoolProfileProperties{
// Count: to.Ptr[int32](3),
// CurrentOrchestratorVersion: to.Ptr("1.9.6"),
// EnableAutoScaling: to.Ptr(true),
// MaxCount: to.Ptr[int32](2),
// MaxPods: to.Ptr[int32](110),
// MinCount: to.Ptr[int32](2),
// NodeTaints: []*string{
// to.Ptr("Key1=Value1:NoSchedule")},
// OrchestratorVersion: to.Ptr("1.9.6"),
// OSType: to.Ptr(armcontainerservice.OSTypeLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// ScaleSetEvictionPolicy: to.Ptr(armcontainerservice.ScaleSetEvictionPolicyDelete),
// ScaleSetPriority: to.Ptr(armcontainerservice.ScaleSetPrioritySpot),
// VMSize: to.Ptr("Standard_DS1_v2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerServiceClient } = require("@azure/arm-containerservice");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an agent pool in the specified managed cluster.
*
* @summary Creates or updates an agent pool in the specified managed cluster.
* x-ms-original-file: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2024-08-01/examples/AgentPools_Update.json
*/
async function updateAgentPool() {
const subscriptionId =
process.env["CONTAINERSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERSERVICE_RESOURCE_GROUP"] || "rg1";
const resourceName = "clustername1";
const agentPoolName = "agentpool1";
const parameters = {
count: 3,
enableAutoScaling: true,
maxCount: 2,
minCount: 2,
nodeTaints: ["Key1=Value1:NoSchedule"],
orchestratorVersion: "",
osType: "Linux",
scaleSetEvictionPolicy: "Delete",
scaleSetPriority: "Spot",
vmSize: "Standard_DS1_v2",
};
const credential = new DefaultAzureCredential();
const client = new ContainerServiceClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateOrUpdateAndWait(
resourceGroupName,
resourceName,
agentPoolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Succeeded",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"enableAutoScaling": true,
"minCount": 2,
"maxCount": 2,
"vmSize": "Standard_DS1_v2",
"maxPods": 110,
"osType": "Linux",
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/clustername1/agentPools/agentpool1",
"type": "Microsoft.ContainerService/managedClusters/agentPools",
"name": "agentpool1",
"properties": {
"provisioningState": "Updating",
"orchestratorVersion": "1.9.6",
"currentOrchestratorVersion": "1.9.6",
"count": 3,
"enableAutoScaling": true,
"minCount": 2,
"maxCount": 2,
"vmSize": "Standard_DS1_v2",
"maxPods": 110,
"osType": "Linux",
"nodeTaints": [
"Key1=Value1:NoSchedule"
],
"scaleSetPriority": "Spot",
"scaleSetEvictionPolicy": "Delete"
}
}
Definitions
AgentPool
Agent Pool.
Name |
Type |
Default value |
Description |
id
|
string
|
|
Resource ID.
|
name
|
string
|
|
The name of the resource that is unique within a resource group. This name can be used to access the resource.
|
properties.availabilityZones
|
string[]
|
|
The list of Availability zones to use for nodes. This can only be specified if the AgentPoolType property is 'VirtualMachineScaleSets'.
|
properties.capacityReservationGroupID
|
string
|
|
The fully qualified resource ID of the Capacity Reservation Group to provide virtual machines from a reserved group of Virtual Machines.
AKS will associate the specified agent pool with the Capacity Reservation Group.
|
properties.count
|
integer
|
|
Number of agents (VMs) to host docker containers. Allowed values must be in the range of 0 to 1000 (inclusive) for user pools and in the range of 1 to 1000 (inclusive) for system pools. The default value is 1.
|
properties.creationData
|
CreationData
|
|
CreationData to be used to specify the source Snapshot ID if the node pool will be created/upgraded using a snapshot.
|
properties.currentOrchestratorVersion
|
string
|
|
The version of Kubernetes the Agent Pool is running.
If orchestratorVersion is a fully specified version <major.minor.patch>, this field will be exactly equal to it. If orchestratorVersion is <major.minor>, this field will contain the full <major.minor.patch> version being used.
|
properties.enableAutoScaling
|
boolean
|
|
Whether to enable auto-scaler
|
properties.enableEncryptionAtHost
|
boolean
|
|
Whether to enable host based OS and data drive encryption.
This is only supported on certain VM sizes and in certain Azure regions. For more information, see: https://docs.microsoft.com/azure/aks/enable-host-encryption
|
properties.enableFIPS
|
boolean
|
|
Whether to use a FIPS-enabled OS.
See Add a FIPS-enabled node pool for more details.
|
properties.enableNodePublicIP
|
boolean
|
|
Whether each node is allocated its own public IP.
Some scenarios may require nodes in a node pool to receive their own dedicated public IP addresses. A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. For more information see assigning a public IP per node. The default is false.
|
properties.enableUltraSSD
|
boolean
|
|
Whether to enable UltraSSD
|
properties.gpuInstanceProfile
|
GPUInstanceProfile
|
|
GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
|
properties.hostGroupID
|
string
|
|
The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from, used only in creation scenario and not allowed to changed once set.
This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}. For more information see Azure dedicated hosts.
|
properties.kubeletConfig
|
KubeletConfig
|
|
Kubelet configurations of agent nodes.
The Kubelet configuration on the agent pool nodes.
|
properties.kubeletDiskType
|
KubeletDiskType
|
|
Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.
|
properties.linuxOSConfig
|
LinuxOSConfig
|
|
OS configurations of Linux agent nodes.
The OS configuration of Linux agent nodes.
|
properties.maxCount
|
integer
|
|
The maximum number of nodes for auto-scaling
|
properties.maxPods
|
integer
|
|
The maximum number of pods that can run on a node.
|
properties.minCount
|
integer
|
|
The minimum number of nodes for auto-scaling
|
properties.mode
|
AgentPoolMode
|
|
The mode of an agent pool.
A cluster must have at least one 'System' Agent Pool at all times. For additional information on agent pool restrictions and best practices, see: https://docs.microsoft.com/azure/aks/use-system-pools
|
properties.networkProfile
|
AgentPoolNetworkProfile
|
|
Network-related settings of an agent pool.
|
properties.nodeImageVersion
|
string
|
|
The version of node image
|
properties.nodeLabels
|
object
|
|
The node labels to be persisted across all nodes in agent pool.
|
properties.nodePublicIPPrefixID
|
string
|
|
The public IP prefix ID which VM nodes should use IPs from.
This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPPrefixes/{publicIPPrefixName}
|
properties.nodeTaints
|
string[]
|
|
The taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule.
|
properties.orchestratorVersion
|
string
|
|
The version of Kubernetes specified by the user.
Both patch version <major.minor.patch> (e.g. 1.20.13) and <major.minor> (e.g. 1.20) are supported. When <major.minor> is specified, the latest supported GA patch version is chosen automatically. Updating the cluster with the same <major.minor> once it has been created (e.g. 1.14.x -> 1.14) will not trigger an upgrade, even if a newer patch version is available. As a best practice, you should upgrade all node pools in an AKS cluster to the same Kubernetes version. The node pool version must have the same major version as the control plane. The node pool minor version must be within two minor versions of the control plane version. The node pool version cannot be greater than the control plane version. For more information see upgrading a node pool.
|
properties.osDiskSizeGB
|
integer
|
|
OS Disk Size in GB to be used to specify the disk size for every machine in the master/agent pool. If you specify 0, it will apply the default osDisk size according to the vmSize specified.
|
properties.osDiskType
|
OSDiskType
|
|
The OS disk type to be used for machines in the agent pool.
The default is 'Ephemeral' if the VM supports it and has a cache disk larger than the requested OSDiskSizeGB. Otherwise, defaults to 'Managed'. May not be changed after creation. For more information see Ephemeral OS.
|
properties.osSKU
|
OSSKU
|
|
Specifies the OS SKU used by the agent pool. The default is Ubuntu if OSType is Linux. The default is Windows2019 when Kubernetes <= 1.24 or Windows2022 when Kubernetes >= 1.25 if OSType is Windows.
|
properties.osType
|
OSType
|
Linux
|
The operating system type. The default is Linux.
|
properties.podSubnetID
|
string
|
|
The ID of the subnet which pods will join when launched.
If omitted, pod IPs are statically assigned on the node subnet (see vnetSubnetID for more details). This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
|
properties.powerState
|
PowerState
|
|
Whether the Agent Pool is running or stopped.
When an Agent Pool is first created it is initially Running. The Agent Pool can be stopped by setting this field to Stopped. A stopped Agent Pool stops all of its VMs and does not accrue billing charges. An Agent Pool can only be stopped if it is Running and provisioning state is Succeeded
|
properties.provisioningState
|
string
|
|
The current deployment or provisioning state.
|
properties.proximityPlacementGroupID
|
string
|
|
The ID for Proximity Placement Group.
|
properties.scaleDownMode
|
ScaleDownMode
|
|
The scale down mode to use when scaling the Agent Pool.
This also effects the cluster autoscaler behavior. If not specified, it defaults to Delete.
|
properties.scaleSetEvictionPolicy
|
ScaleSetEvictionPolicy
|
Delete
|
The Virtual Machine Scale Set eviction policy to use.
This cannot be specified unless the scaleSetPriority is 'Spot'. If not specified, the default is 'Delete'.
|
properties.scaleSetPriority
|
ScaleSetPriority
|
Regular
|
The Virtual Machine Scale Set priority. If not specified, the default is 'Regular'.
|
properties.securityProfile
|
AgentPoolSecurityProfile
|
|
The security settings of an agent pool.
|
properties.spotMaxPrice
|
number
|
-1
|
The max price (in US Dollars) you are willing to pay for spot instances. Possible values are any decimal value greater than zero or -1 which indicates default price to be up-to on-demand.
Possible values are any decimal value greater than zero or -1 which indicates the willingness to pay any on-demand price. For more details on spot pricing, see spot VMs pricing
|
properties.tags
|
object
|
|
The tags to be persisted on the agent pool virtual machine scale set.
|
properties.type
|
AgentPoolType
|
|
The type of Agent Pool.
|
properties.upgradeSettings
|
AgentPoolUpgradeSettings
|
|
Settings for upgrading the agentpool
|
properties.vmSize
|
string
|
|
The size of the agent pool VMs.
VM size availability varies by region. If a node contains insufficient compute resources (memory, cpu, etc) pods might fail to run correctly. For more details on restricted VM sizes, see: https://docs.microsoft.com/azure/aks/quotas-skus-regions
|
properties.vnetSubnetID
|
string
|
|
The ID of the subnet which agent pool nodes and optionally pods will join on startup.
If this is not specified, a VNET and subnet will be generated and used. If no podSubnetID is specified, this applies to nodes and pods, otherwise it applies to just nodes. This is of the form: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
|
properties.windowsProfile
|
AgentPoolWindowsProfile
|
|
The Windows agent pool's specific profile.
|
properties.workloadRuntime
|
WorkloadRuntime
|
|
Determines the type of workload a node can run.
|
type
|
string
|
|
Resource type
|
AgentPoolMode
The mode of an agent pool.
Name |
Type |
Description |
System
|
string
|
System agent pools are primarily for hosting critical system pods such as CoreDNS and metrics-server. System agent pools osType must be Linux. System agent pools VM SKU must have at least 2vCPUs and 4GB of memory.
|
User
|
string
|
User agent pools are primarily for hosting your application pods.
|
AgentPoolNetworkProfile
Network settings of an agent pool.
Name |
Type |
Description |
allowedHostPorts
|
PortRange[]
|
The port ranges that are allowed to access. The specified ranges are allowed to overlap.
|
applicationSecurityGroups
|
string[]
|
The IDs of the application security groups which agent pool will associate when created.
|
nodePublicIPTags
|
IPTag[]
|
IPTags of instance-level public IPs.
|
AgentPoolSecurityProfile
The security settings of an agent pool.
Name |
Type |
Description |
enableSecureBoot
|
boolean
|
Secure Boot is a feature of Trusted Launch which ensures that only signed operating systems and drivers can boot. For more details, see aka.ms/aks/trustedlaunch. If not specified, the default is false.
|
enableVTPM
|
boolean
|
vTPM is a Trusted Launch feature for configuring a dedicated secure vault for keys and measurements held locally on the node. For more details, see aka.ms/aks/trustedlaunch. If not specified, the default is false.
|
AgentPoolType
The type of Agent Pool.
Name |
Type |
Description |
AvailabilitySet
|
string
|
Use of this is strongly discouraged.
|
VirtualMachineScaleSets
|
string
|
Create an Agent Pool backed by a Virtual Machine Scale Set.
|
AgentPoolUpgradeSettings
Settings for upgrading an agentpool
Name |
Type |
Description |
drainTimeoutInMinutes
|
integer
|
The drain timeout for a node
The amount of time (in minutes) to wait on eviction of pods and graceful termination per node. This eviction wait time honors waiting on pod disruption budgets. If this time is exceeded, the upgrade fails. If not specified, the default is 30 minutes.
|
maxSurge
|
string
|
The maximum number or percentage of nodes that are surged during upgrade.
This can either be set to an integer (e.g. '5') or a percentage (e.g. '50%'). If a percentage is specified, it is the percentage of the total agent pool size at the time of the upgrade. For percentages, fractional nodes are rounded up. If not specified, the default is 1. For more information, including best practices, see: https://docs.microsoft.com/azure/aks/upgrade-cluster#customize-node-surge-upgrade
|
nodeSoakDurationInMinutes
|
integer
|
The soak duration for a node
The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node. If not specified, the default is 0 minutes.
|
AgentPoolWindowsProfile
The Windows agent pool's specific profile.
Name |
Type |
Description |
disableOutboundNat
|
boolean
|
Whether to disable OutboundNAT in windows nodes
The default value is false. Outbound NAT can only be disabled if the cluster outboundType is NAT Gateway and the Windows agent pool does not have node public IP enabled.
|
CloudError
An error response from the Container service.
CloudErrorBody
An error response from the Container service.
Name |
Type |
Description |
code
|
string
|
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
|
details
|
CloudErrorBody[]
|
A list of additional details about the error.
|
message
|
string
|
A message describing the error, intended to be suitable for display in a user interface.
|
target
|
string
|
The target of the particular error. For example, the name of the property in error.
|
code
Tells whether the cluster is Running or Stopped
Name |
Type |
Description |
Running
|
string
|
The cluster is running.
|
Stopped
|
string
|
The cluster is stopped.
|
CreationData
Data used when creating a target resource from a source resource.
Name |
Type |
Description |
sourceResourceId
|
string
|
This is the ARM ID of the source object to be used to create the target object.
|
GPUInstanceProfile
GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
Name |
Type |
Description |
MIG1g
|
string
|
|
MIG2g
|
string
|
|
MIG3g
|
string
|
|
MIG4g
|
string
|
|
MIG7g
|
string
|
|
IPTag
Contains the IPTag associated with the object.
Name |
Type |
Description |
ipTagType
|
string
|
The IP tag type. Example: RoutingPreference.
|
tag
|
string
|
The value of the IP tag associated with the public IP. Example: Internet.
|
KubeletConfig
Kubelet configurations of agent nodes.
Name |
Type |
Description |
allowedUnsafeSysctls
|
string[]
|
Allowed list of unsafe sysctls or unsafe sysctl patterns (ending in * ).
|
containerLogMaxFiles
|
integer
|
The maximum number of container log files that can be present for a container. The number must be ≥ 2.
|
containerLogMaxSizeMB
|
integer
|
The maximum size (e.g. 10Mi) of container log file before it is rotated.
|
cpuCfsQuota
|
boolean
|
If CPU CFS quota enforcement is enabled for containers that specify CPU limits.
The default is true.
|
cpuCfsQuotaPeriod
|
string
|
The CPU CFS quota period value.
The default is '100ms.' Valid values are a sequence of decimal numbers with an optional fraction and a unit suffix. For example: '300ms', '2h45m'. Supported units are 'ns', 'us', 'ms', 's', 'm', and 'h'.
|
cpuManagerPolicy
|
string
|
The CPU Manager policy to use.
The default is 'none'. See Kubernetes CPU management policies for more information. Allowed values are 'none' and 'static'.
|
failSwapOn
|
boolean
|
If set to true it will make the Kubelet fail to start if swap is enabled on the node.
|
imageGcHighThreshold
|
integer
|
The percent of disk usage after which image garbage collection is always run.
To disable image garbage collection, set to 100. The default is 85%
|
imageGcLowThreshold
|
integer
|
The percent of disk usage before which image garbage collection is never run.
This cannot be set higher than imageGcHighThreshold. The default is 80%
|
podMaxPids
|
integer
|
The maximum number of processes per pod.
|
topologyManagerPolicy
|
string
|
The Topology Manager policy to use.
For more information see Kubernetes Topology Manager. The default is 'none'. Allowed values are 'none', 'best-effort', 'restricted', and 'single-numa-node'.
|
KubeletDiskType
Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.
Name |
Type |
Description |
OS
|
string
|
Kubelet will use the OS disk for its data.
|
Temporary
|
string
|
Kubelet will use the temporary disk for its data.
|
LinuxOSConfig
OS configurations of Linux agent nodes.
Name |
Type |
Description |
swapFileSizeMB
|
integer
|
The size in MB of a swap file that will be created on each node.
|
sysctls
|
SysctlConfig
|
Sysctl settings for Linux agent nodes.
|
transparentHugePageDefrag
|
string
|
Whether the kernel should make aggressive use of memory compaction to make more hugepages available.
Valid values are 'always', 'defer', 'defer+madvise', 'madvise' and 'never'. The default is 'madvise'. For more information see Transparent Hugepages.
|
transparentHugePageEnabled
|
string
|
Whether transparent hugepages are enabled.
Valid values are 'always', 'madvise', and 'never'. The default is 'always'. For more information see Transparent Hugepages.
|
OSDiskType
The OS disk type to be used for machines in the agent pool.
Name |
Type |
Description |
Ephemeral
|
string
|
Ephemeral OS disks are stored only on the host machine, just like a temporary disk. This provides lower read/write latency, along with faster node scaling and cluster upgrades.
|
Managed
|
string
|
Azure replicates the operating system disk for a virtual machine to Azure storage to avoid data loss should the VM need to be relocated to another host. Since containers aren't designed to have local state persisted, this behavior offers limited value while providing some drawbacks, including slower node provisioning and higher read/write latency.
|
OSSKU
Specifies the OS SKU used by the agent pool. The default is Ubuntu if OSType is Linux. The default is Windows2019 when Kubernetes <= 1.24 or Windows2022 when Kubernetes >= 1.25 if OSType is Windows.
Name |
Type |
Description |
AzureLinux
|
string
|
Use AzureLinux as the OS for node images. Azure Linux is a container-optimized Linux distro built by Microsoft, visit https://aka.ms/azurelinux for more information.
|
CBLMariner
|
string
|
Deprecated OSSKU. Microsoft recommends that new deployments choose 'AzureLinux' instead.
|
Ubuntu
|
string
|
Use Ubuntu as the OS for node images.
|
Windows2019
|
string
|
Use Windows2019 as the OS for node images. Unsupported for system node pools. Windows2019 only supports Windows2019 containers; it cannot run Windows2022 containers and vice versa.
|
Windows2022
|
string
|
Use Windows2022 as the OS for node images. Unsupported for system node pools. Windows2022 only supports Windows2022 containers; it cannot run Windows2019 containers and vice versa.
|
OSType
The operating system type. The default is Linux.
Name |
Type |
Description |
Linux
|
string
|
Use Linux.
|
Windows
|
string
|
Use Windows.
|
PortRange
The port range.
Name |
Type |
Description |
portEnd
|
integer
|
The maximum port that is included in the range. It should be ranged from 1 to 65535, and be greater than or equal to portStart.
|
portStart
|
integer
|
The minimum port that is included in the range. It should be ranged from 1 to 65535, and be less than or equal to portEnd.
|
protocol
|
Protocol
|
The network protocol of the port.
|
PowerState
Describes the Power State of the cluster
Name |
Type |
Description |
code
|
code
|
Tells whether the cluster is Running or Stopped
|
Protocol
The network protocol of the port.
Name |
Type |
Description |
TCP
|
string
|
TCP protocol.
|
UDP
|
string
|
UDP protocol.
|
ScaleDownMode
Describes how VMs are added to or removed from Agent Pools. See billing states.
Name |
Type |
Description |
Deallocate
|
string
|
Attempt to start deallocated instances (if they exist) during scale up and deallocate instances during scale down.
|
Delete
|
string
|
Create new instances during scale up and remove instances during scale down.
|
ScaleSetEvictionPolicy
The Virtual Machine Scale Set eviction policy.
Name |
Type |
Description |
Deallocate
|
string
|
Nodes in the underlying Scale Set of the node pool are set to the stopped-deallocated state upon eviction. Nodes in the stopped-deallocated state count against your compute quota and can cause issues with cluster scaling or upgrading.
|
Delete
|
string
|
Nodes in the underlying Scale Set of the node pool are deleted when they're evicted.
|
ScaleSetPriority
The Virtual Machine Scale Set priority.
Name |
Type |
Description |
Regular
|
string
|
Regular VMs will be used.
|
Spot
|
string
|
Spot priority VMs will be used. There is no SLA for spot nodes. See spot on AKS for more information.
|
SysctlConfig
Sysctl settings for Linux agent nodes.
Name |
Type |
Description |
fsAioMaxNr
|
integer
|
Sysctl setting fs.aio-max-nr.
|
fsFileMax
|
integer
|
Sysctl setting fs.file-max.
|
fsInotifyMaxUserWatches
|
integer
|
Sysctl setting fs.inotify.max_user_watches.
|
fsNrOpen
|
integer
|
Sysctl setting fs.nr_open.
|
kernelThreadsMax
|
integer
|
Sysctl setting kernel.threads-max.
|
netCoreNetdevMaxBacklog
|
integer
|
Sysctl setting net.core.netdev_max_backlog.
|
netCoreOptmemMax
|
integer
|
Sysctl setting net.core.optmem_max.
|
netCoreRmemDefault
|
integer
|
Sysctl setting net.core.rmem_default.
|
netCoreRmemMax
|
integer
|
Sysctl setting net.core.rmem_max.
|
netCoreSomaxconn
|
integer
|
Sysctl setting net.core.somaxconn.
|
netCoreWmemDefault
|
integer
|
Sysctl setting net.core.wmem_default.
|
netCoreWmemMax
|
integer
|
Sysctl setting net.core.wmem_max.
|
netIpv4IpLocalPortRange
|
string
|
Sysctl setting net.ipv4.ip_local_port_range.
|
netIpv4NeighDefaultGcThresh1
|
integer
|
Sysctl setting net.ipv4.neigh.default.gc_thresh1.
|
netIpv4NeighDefaultGcThresh2
|
integer
|
Sysctl setting net.ipv4.neigh.default.gc_thresh2.
|
netIpv4NeighDefaultGcThresh3
|
integer
|
Sysctl setting net.ipv4.neigh.default.gc_thresh3.
|
netIpv4TcpFinTimeout
|
integer
|
Sysctl setting net.ipv4.tcp_fin_timeout.
|
netIpv4TcpKeepaliveProbes
|
integer
|
Sysctl setting net.ipv4.tcp_keepalive_probes.
|
netIpv4TcpKeepaliveTime
|
integer
|
Sysctl setting net.ipv4.tcp_keepalive_time.
|
netIpv4TcpMaxSynBacklog
|
integer
|
Sysctl setting net.ipv4.tcp_max_syn_backlog.
|
netIpv4TcpMaxTwBuckets
|
integer
|
Sysctl setting net.ipv4.tcp_max_tw_buckets.
|
netIpv4TcpTwReuse
|
boolean
|
Sysctl setting net.ipv4.tcp_tw_reuse.
|
netIpv4TcpkeepaliveIntvl
|
integer
|
Sysctl setting net.ipv4.tcp_keepalive_intvl.
|
netNetfilterNfConntrackBuckets
|
integer
|
Sysctl setting net.netfilter.nf_conntrack_buckets.
|
netNetfilterNfConntrackMax
|
integer
|
Sysctl setting net.netfilter.nf_conntrack_max.
|
vmMaxMapCount
|
integer
|
Sysctl setting vm.max_map_count.
|
vmSwappiness
|
integer
|
Sysctl setting vm.swappiness.
|
vmVfsCachePressure
|
integer
|
Sysctl setting vm.vfs_cache_pressure.
|
WorkloadRuntime
Determines the type of workload a node can run.
Name |
Type |
Description |
OCIContainer
|
string
|
Nodes will use Kubelet to run standard OCI container workloads.
|
WasmWasi
|
string
|
Nodes will use Krustlet to run WASM workloads using the WASI provider (Preview).
|