Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
CONST_NETWORK_POLICY_CALICO = "calico"
CONST_NETWORK_POLICY_NONE = "none"

# network pod ip allocation mode
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL = "DynamicIndividual"
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK = "StaticBlock"

# consts for addons
# http application routing
CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME = "httpApplicationRouting"
Expand Down
16 changes: 16 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@
- name: --pod-subnet-id
type: string
short-summary: The ID of a subnet in an existing VNet into which to assign pods in the cluster (requires azure network-plugin).
- name: --pod-ip-allocation-mode
type: string
short-summary: Set the ip allocation mode for how Pod IPs from the Azure Pod Subnet are allocated to the nodes in the AKS cluster. The choice is between dynamic batches of individual IPs or static allocation of a set of CIDR blocks. Accepted Values are "DynamicIndividual" or "StaticBlock".
Comment thread
nairashu marked this conversation as resolved.
long-summary: |
Used together with the "azure" network plugin.
Requires --pod-subnet-id.
- name: --ppg
type: string
short-summary: The ID of a PPG.
Expand Down Expand Up @@ -662,6 +668,8 @@
text: az aks create -g MyResourceGroup -n MyMC --kubernetes-version 1.20.9 --node-vm-size VMSize --assign-identity "subscriptions/SubID/resourceGroups/RGName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myID" --enable-managed-identity --crg-id "subscriptions/SubID/resourceGroups/RGName/providers/Microsoft.ContainerService/CapacityReservationGroups/MyCRGID"
- name: Create a kubernetes cluster with Azure Service Mesh enabled.
text: az aks create -g MyResourceGroup -n MyManagedCluster --enable-azure-service-mesh
- name: Create a kubernetes cluster with a nodepool having ip allocation mode set to "StaticBlock"
text: az aks create -g MyResourceGroup -n MyManagedCluster --os-sku Ubuntu --max-pods MaxPodsPerNode --network-plugin azure --vnet-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/NodeSubnet --pod-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/PodSubnet --pod-ip-allocation-mode StaticBlock
"""

helps['aks update'] = """
Expand Down Expand Up @@ -1595,6 +1603,12 @@
- name: --pod-subnet-id
type: string
short-summary: The Resource Id of a subnet in an existing VNet into which to assign pods in the cluster (requires azure network-plugin).
- name: --pod-ip-allocation-mode
type: string
short-summary: Set the ip allocation mode for how Pod IPs from the Azure Pod Subnet are allocated to the nodes in the AKS cluster. The choice is between dynamic batches of individual IPs or static allocation of a set of CIDR blocks. Accepted Values are "DynamicIndividual" or "StaticBlock".
long-summary: |
Used together with the "azure" network plugin.
Requires --pod-subnet-id.
- name: --ppg
type: string
short-summary: The ID of a PPG.
Expand Down Expand Up @@ -1729,6 +1743,8 @@
text: az aks nodepool add -g MyResourceGroup -n MyNodePool --cluster-name MyMC --host-group-id /subscriptions/00000/resourceGroups/AnotherResourceGroup/providers/Microsoft.ContainerService/hostGroups/myHostGroup --node-vm-size VMSize
- name: create a nodepool with a Capacity Reservation Group(CRG) ID.
text: az aks nodepool add -g MyResourceGroup -n MyNodePool --cluster-name MyMC --node-vm-size VMSize --crg-id "/subscriptions/SubID/resourceGroups/ResourceGroupName/providers/Microsoft.ContainerService/CapacityReservationGroups/MyCRGID"
- name: Create a nodepool with ip allocation mode set to "StaticBlock" and using a pod subnet ID
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --os-sku Ubuntu --pod-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/MySubnet --pod-ip-allocation-mode StaticBlock
"""

helps['aks nodepool delete'] = """
Expand Down
5 changes: 5 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
CONST_NETWORK_POLICY_AZURE, CONST_NETWORK_POLICY_CALICO, CONST_NETWORK_POLICY_CILIUM, CONST_NETWORK_POLICY_NONE,
CONST_NETWORK_PLUGIN_AZURE, CONST_NETWORK_PLUGIN_KUBENET,
CONST_NETWORK_PLUGIN_MODE_OVERLAY, CONST_NETWORK_PLUGIN_NONE,
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL,
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK,
CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL,
CONST_NODE_OS_CHANNEL_NODE_IMAGE,
CONST_NODE_OS_CHANNEL_NONE,
Expand Down Expand Up @@ -165,6 +167,7 @@
node_os_skus = node_os_skus_create + [CONST_OS_SKU_WINDOWS2019, CONST_OS_SKU_WINDOWS2022]
node_os_skus_update = [CONST_OS_SKU_AZURELINUX, CONST_OS_SKU_UBUNTU, CONST_OS_SKU_UBUNTU2204]
scale_down_modes = [CONST_SCALE_DOWN_MODE_DELETE, CONST_SCALE_DOWN_MODE_DEALLOCATE]
pod_ip_allocation_modes = [CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL, CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK]

# consts for ManagedCluster
load_balancer_skus = [CONST_LOAD_BALANCER_SKU_BASIC, CONST_LOAD_BALANCER_SKU_STANDARD]
Expand Down Expand Up @@ -446,6 +449,7 @@ def load_arguments(self, _):
c.argument('snapshot_id', validator=validate_snapshot_id)
c.argument('vnet_subnet_id', validator=validate_vnet_subnet_id)
c.argument('pod_subnet_id', validator=validate_pod_subnet_id)
c.argument('pod_ip_allocation_mode', arg_type=get_enum_type(pod_ip_allocation_modes))
c.argument('enable_node_public_ip', action='store_true')
c.argument('node_public_ip_prefix_id')
c.argument('enable_cluster_autoscaler', action='store_true')
Expand Down Expand Up @@ -824,6 +828,7 @@ def load_arguments(self, _):
c.argument('snapshot_id', validator=validate_snapshot_id)
c.argument('vnet_subnet_id', validator=validate_vnet_subnet_id)
c.argument('pod_subnet_id', validator=validate_pod_subnet_id)
c.argument('pod_ip_allocation_mode', arg_type=get_enum_type(pod_ip_allocation_modes))
c.argument('enable_node_public_ip', action='store_true')
c.argument('node_public_ip_prefix_id')
c.argument('enable_cluster_autoscaler', options_list=["--enable-cluster-autoscaler", "-e"], action='store_true')
Expand Down
12 changes: 12 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
CONST_OS_SKU_AZURELINUX,
CONST_OS_SKU_CBLMARINER,
CONST_OS_SKU_MARINER,
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL,
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK,
CONST_NODEPOOL_MODE_GATEWAY,
)
from azure.cli.core import keys
Expand Down Expand Up @@ -372,6 +374,16 @@ def validate_pod_subnet_id(namespace):
_validate_subnet_id(namespace.pod_subnet_id, "--pod-subnet-id")


def validate_pod_ip_allocation_mode(namespace):
"""Validates the pod ip allocation mode string."""
if namespace.pod_ip_allocation_mode is not None:
if namespace.pod_ip_allocation_mode not in (
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL,
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK,
):
raise InvalidArgumentValueError("--pod-ip-allocation-mode can only be DynamicIndividual or StaticBlock")


def validate_apiserver_subnet_id(namespace):
_validate_subnet_id(namespace.apiserver_subnet_id, "--apiserver-subnet-id")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,26 @@ def get_pod_subnet_id(self) -> Union[str, None]:
# this parameter does not need validation
return pod_subnet_id

def get_pod_ip_allocation_mode(self: bool = False) -> Union[str, None]:
"""Get the value of pod_ip_allocation_mode.

:return: str or None
"""

# Get the value of pod_ip_allocation_mode from the raw parameters provided by the user
pod_ip_allocation_mode = self.raw_param.get("pod_ip_allocation_mode")
# In create mode, try to read the property value corresponding to the parameter from the `agentpool` object
# if it exists and user has not provided any value in raw parameters
if self.decorator_mode == DecoratorMode.CREATE:
if (
pod_ip_allocation_mode and
self.agentpool and
self.agentpool.pod_ip_allocation_mode is not None
):
pod_ip_allocation_mode = self.agentpool.pod_ip_allocation_mode

return pod_ip_allocation_mode

def get_enable_node_public_ip(self) -> bool:
"""Obtain the value of enable_node_public_ip, default value is False.

Expand Down Expand Up @@ -1785,6 +1805,7 @@ def set_up_node_network_properties(self, agentpool: AgentPool) -> AgentPool:

agentpool.vnet_subnet_id = self.context.get_vnet_subnet_id()
agentpool.pod_subnet_id = self.context.get_pod_subnet_id()
agentpool.pod_ip_allocation_mode = self.context.get_pod_ip_allocation_mode()
Comment thread
nairashu marked this conversation as resolved.
agentpool.enable_node_public_ip = self.context.get_enable_node_public_ip()
agentpool.node_public_ip_prefix_id = self.context.get_node_public_ip_prefix_id()
return agentpool
Expand Down Expand Up @@ -2030,6 +2051,19 @@ def set_up_agentpool_gateway_profile(self, agentpool: AgentPool) -> AgentPool:

Comment thread
nairashu marked this conversation as resolved.
return agentpool

def set_up_pod_ip_allocation_mode(self, agentpool: AgentPool) -> AgentPool:
"""Set up pod ip allocation mode for the AgentPool object.

:return: the AgentPool object
"""
self._ensure_agentpool(agentpool)

pod_ip_allocation_mode = self.context.get_pod_ip_allocation_mode()
if pod_ip_allocation_mode is not None:
agentpool.pod_ip_allocation_mode = pod_ip_allocation_mode

return agentpool

def construct_agentpool_profile_default(self, bypass_restore_defaults: bool = False) -> AgentPool:
"""The overall controller used to construct the AgentPool profile by default.

Expand Down Expand Up @@ -2066,6 +2100,8 @@ def construct_agentpool_profile_default(self, bypass_restore_defaults: bool = Fa
agentpool = self.set_up_gpu_properties(agentpool)
# set up agentpool network profile
agentpool = self.set_up_agentpool_network_profile(agentpool)
# set up agentpool pod ip allocation mode
agentpool = self.set_up_pod_ip_allocation_mode(agentpool)
# set up agentpool windows profile
agentpool = self.set_up_agentpool_windows_profile(agentpool)
# set up crg id
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ def aks_create(
snapshot_id=None,
vnet_subnet_id=None,
pod_subnet_id=None,
pod_ip_allocation_mode=None,
enable_node_public_ip=False,
node_public_ip_prefix_id=None,
enable_cluster_autoscaler=False,
Expand Down Expand Up @@ -2396,6 +2397,7 @@ def aks_agentpool_add(
snapshot_id=None,
vnet_subnet_id=None,
pod_subnet_id=None,
pod_ip_allocation_mode=None,
enable_node_public_ip=False,
node_public_ip_prefix_id=None,
enable_cluster_autoscaler=False,
Expand Down
Loading
Loading