Microsoft Azure Container Service Management Client Library for Python
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Node pool management operations for AKS clusters including system and user node pools, auto-scaling configuration, OS and VM size selection, and maintenance operations. Agent pools represent groups of nodes with identical configurations within a managed cluster.
Get information about existing agent pools in an AKS cluster.
def get(
resource_group_name: str,
resource_name: str,
agent_pool_name: str,
**kwargs
) -> AgentPool:
"""
Get the specified agent pool.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
- agent_pool_name (str): The name of the agent pool
Returns:
AgentPool: The agent pool resource
"""Usage example:
agent_pool = client.agent_pools.get("my-rg", "my-cluster", "nodepool1")
print(f"Node count: {agent_pool.count}")
print(f"VM size: {agent_pool.vm_size}")
print(f"OS type: {agent_pool.os_type}")Create new agent pools or update existing ones with comprehensive configuration options.
def begin_create_or_update(
resource_group_name: str,
resource_name: str,
agent_pool_name: str,
parameters: AgentPool,
**kwargs
) -> LROPoller[AgentPool]:
"""
Create or update an agent pool.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
- agent_pool_name (str): The name of the agent pool
- parameters (AgentPool): The agent pool specification
Returns:
LROPoller[AgentPool]: Long-running operation poller
"""Usage example:
from azure.mgmt.containerservice.models import AgentPool, AgentPoolUpgradeSettings
# Create agent pool configuration
agent_pool_config = AgentPool(
count=3,
vm_size="Standard_D4s_v3",
os_type="Linux",
mode="User",
max_pods=110,
enable_auto_scaling=True,
min_count=1,
max_count=10,
upgrade_settings=AgentPoolUpgradeSettings(
max_surge="1"
),
node_labels={"environment": "production"},
node_taints=["workload=gpu:NoSchedule"]
)
# Create agent pool
operation = client.agent_pools.create_or_update(
"my-rg", "my-cluster", "gpu-pool", agent_pool_config
)
agent_pool = operation.result()
print(f"Agent pool created: {agent_pool.name}")List all agent pools in a managed cluster.
def list(
resource_group_name: str,
resource_name: str,
**kwargs
) -> ItemPaged[AgentPool]:
"""
Get a list of agent pools in the specified managed cluster.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
Returns:
ItemPaged[AgentPool]: Paginated list of agent pools
"""Delete agent pools from AKS clusters.
def begin_delete(
resource_group_name: str,
resource_name: str,
agent_pool_name: str,
ignore_pod_disruption_budget: bool = None,
**kwargs
) -> LROPoller[None]:
"""
Delete an agent pool.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
- agent_pool_name (str): The name of the agent pool
- ignore_pod_disruption_budget (bool): Ignore PodDisruptionBudget during deletion
Returns:
LROPoller[None]: Long-running operation poller
"""Manage agent pool upgrades and get available versions.
def get_available_agent_pool_versions(
resource_group_name: str,
resource_name: str,
**kwargs
) -> AgentPoolAvailableVersions:
"""
Get available upgrade versions for agent pools.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
Returns:
AgentPoolAvailableVersions: Available versions for agent pools
"""
def get_upgrade_profile(
resource_group_name: str,
resource_name: str,
agent_pool_name: str,
**kwargs
) -> AgentPoolUpgradeProfile:
"""
Get upgrade profile for an agent pool.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
- agent_pool_name (str): The name of the agent pool
Returns:
AgentPoolUpgradeProfile: Upgrade profile with available versions
"""Manage individual machines within agent pools.
def delete_machines(
resource_group_name: str,
resource_name: str,
agent_pool_name: str,
machine_names: AgentPoolDeleteMachinesParameter,
**kwargs
) -> LROPoller[None]:
"""
Delete specific machines from an agent pool.
Parameters:
- resource_group_name (str): The name of the resource group
- resource_name (str): The name of the managed cluster
- agent_pool_name (str): The name of the agent pool
- machine_names (AgentPoolDeleteMachinesParameter): Machine names to delete
Returns:
LROPoller[None]: Long-running operation poller
"""class AgentPool:
"""
Agent pool resource representing a group of nodes.
Attributes:
- count (int): Number of nodes in the agent pool
- vm_size (str): VM size for nodes (e.g., Standard_D2s_v3)
- os_disk_size_gb (int): OS disk size in GB
- os_type (str): OS type (Linux, Windows)
- max_pods (int): Maximum pods per node
- type (str): Agent pool type (VirtualMachineScaleSets, AvailabilitySet)
- mode (str): Agent pool mode (System, User)
- orchestrator_version (str): Kubernetes version
- provisioning_state (str): Provisioning state
- power_state (PowerState): Current power state
- availability_zones (List[str]): Availability zones
- enable_auto_scaling (bool): Enable auto-scaling
- min_count (int): Minimum node count (when auto-scaling enabled)
- max_count (int): Maximum node count (when auto-scaling enabled)
- enable_node_public_ip (bool): Enable public IP on nodes
- scale_down_mode (str): Scale down mode (Delete, Deallocate)
- spot_max_price (float): Max price for spot instances
- tags (Dict[str, str]): Resource tags
- node_labels (Dict[str, str]): Kubernetes node labels
- node_taints (List[str]): Kubernetes node taints
- proximity_placement_group_id (str): Proximity placement group ID
- upgrade_settings (AgentPoolUpgradeSettings): Upgrade settings
- enable_encryption_at_host (bool): Enable encryption at host
- enable_ultra_ssd (bool): Enable Ultra SSD
- gpu_instance_profile (str): GPU instance profile
- workload_runtime (str): Workload runtime (OCIContainer, WasmWasi)
- network_profile (AgentPoolNetworkProfile): Network configuration
- windows_profile (AgentPoolWindowsProfile): Windows-specific configuration
"""class AgentPoolUpgradeSettings:
"""
Agent pool upgrade settings.
Attributes:
- max_surge (str): Maximum number of nodes that can be created during upgrade
- drain_timeout_in_minutes (int): Drain timeout in minutes
- node_soak_duration_in_minutes (int): Node soak duration in minutes
"""class AgentPoolDeleteMachinesParameter:
"""
Parameters for deleting specific machines from an agent pool.
Attributes:
- machine_names (List[str]): List of machine names to delete
"""Agent pools can operate in two modes:
Configure horizontal pod autoscaler for dynamic node scaling:
agent_pool = AgentPool(
count=3, # Initial count
enable_auto_scaling=True,
min_count=1, # Minimum nodes
max_count=10, # Maximum nodes
vm_size="Standard_D2s_v3"
)All operations have async equivalents:
from azure.mgmt.containerservice.aio import ContainerServiceClient
async with ContainerServiceClient(credential, subscription_id) as client:
agent_pool = await client.agent_pools.get("my-rg", "my-cluster", "nodepool1")
# Long-running operations
operation = await client.agent_pools.begin_create_or_update(
"my-rg", "my-cluster", "new-pool", agent_pool_config
)
result = await operation.result()Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-containerservice