Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6a45326
Adding the cli command option for --pod-ip-allocation-mode
Feb 14, 2024
4d3522b
Added all the fields to read and populate the pod ip allocation mode …
Feb 15, 2024
b2ada0b
Addressed all the code review comments by removing the Unassigned fro…
Feb 21, 2024
7aed936
Added a UT for the new podIPAllocationProperty
Feb 21, 2024
cf31fda
Added the new UT to be called on the required decorators
Feb 21, 2024
6557fd0
Added a live test case for podIPAllocationMode and creating a StaticB…
Feb 21, 2024
2272726
Added the necessary space
Feb 21, 2024
e1580d3
Simplified the logic to read from the agentpool profile if the value …
Feb 21, 2024
9ed4b7d
Trying to fix the linter issues
Feb 22, 2024
b4a113d
Updated the code to adhere to the azdev styles
Feb 22, 2024
fde8789
Fixed errors to adhere to the azdev styles
Feb 22, 2024
4516aaa
Attempting to not initialize any pod-ip-allocation-mode by default an…
Feb 22, 2024
da0e473
Fixed param list
Feb 22, 2024
4d6de3f
Adding the live only tag for the live test added
Feb 22, 2024
6882dfd
Fixed the missing '-' from the max-pods argument
Feb 22, 2024
3ad89a1
Attempting to fix the resource ID for the node subnet
Feb 22, 2024
24a52a2
Attempting to fix the resource ID for the node subnet
Feb 22, 2024
5953766
Fixed the property name of the agentpoolprofile
Feb 22, 2024
4cad504
Updated the expected value for podSubnetID
Feb 23, 2024
88ff1e1
Added the logic to add the podIPAllocationMode to the agentpool netwo…
Feb 23, 2024
0c1276b
Removed the reference to agentpool network profile
Feb 23, 2024
256a1bf
Added a test case for managed_cluster properties generation
Feb 23, 2024
83bc419
Added methods to update the pod ip allocation mode property of the ag…
Feb 23, 2024
15ebd05
Fixing the variable name in the live test aks_name
Feb 23, 2024
3035ee2
Added the live test recording to the PR
Feb 23, 2024
5bbc405
Updated the PR based on the review comments to reorder the logic in t…
Feb 26, 2024
c587768
Updated the test cases based on the suggestions made in the PR review
Feb 27, 2024
30feb66
Upated the History and setup.py files after rebasing to merge the new…
Feb 28, 2024
c50184d
Fixed the assertion value
Feb 28, 2024
3572460
Fixed the azdev styles issue
Feb 28, 2024
b1e48ee
Removed the liveonly tag
Feb 29, 2024
d519a51
Excluding the test from the live test as it requires feature registra…
Feb 29, 2024
1703660
Update src/aks-preview/azext_aks_preview/_help.py based on the sugges…
nairashu Feb 29, 2024
39ad6cb
Update src/aks-preview/azext_aks_preview/_help.py to use first-person…
nairashu Feb 29, 2024
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/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ If there is no rush to release a new version, please just add a description of t

To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.

2.0.0b2
+++++++
* Add `--pod-ip-allocation-mode` to `az aks create` and `az aks nodepool` commands.

2.0.0b1
+++++++
* [BREAKING CHANGE] Replace `guardrails` parameters with `safeguards`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"overlay migration, missing toggle": [
"test_aks_azure_cni_overlay_migration"
],
"pod ip allocation mode static block, missing feature registration": [
"test_aks_create_with_pod_ip_allocation_mode_static_block"
],
"slb to nat gateway": [
"test_aks_update_outbound_from_slb_to_natgateway"
],
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
CONST_NETWORK_POLICY_CILIUM = "cilium"
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"

# disk driver versions
CONST_DISK_DRIVER_V1 = "v1"
CONST_DISK_DRIVER_V2 = "v2"
Expand Down
16 changes: 16 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@
- name: --ssh-access
type: string
short-summary: Configure SSH setting for all node pools in this cluster. Use "disabled" to disable SSH access, "localuser" to enable SSH access using private key.
- 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.
examples:
- name: Create a Kubernetes cluster with an existing SSH public key.
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey
Expand Down Expand Up @@ -665,6 +671,8 @@
text: az aks create -g MyResourceGroup -n MyManagedCluster --enable-azure-service-mesh
- name: Create a kubernetes cluster with Azure Monitor Metrics enabled.
text: az aks create -g MyResourceGroup -n MyManagedCluster --enable-azuremonitormetrics
- 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/00000/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/NodeSubnet --pod-subnet-id /subscriptions/00000/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/PodSubnet --pod-ip-allocation-mode StaticBlock

"""

Expand Down Expand Up @@ -1725,6 +1733,12 @@
- name: --ssh-access
type: string
short-summary: Configure SSH setting for the node pool. Use "disabled" to disable SSH access, "localuser" to enable SSH access using private key.
- 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.
examples:
- name: Create a nodepool in an existing AKS cluster with ephemeral os enabled.
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --node-osdisk-type Ephemeral --node-osdisk-size 48
Expand All @@ -1740,6 +1754,8 @@
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 in an existing AKS cluster with host group id
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 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/00000/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/MySubnet --pod-ip-allocation-mode StaticBlock
"""

helps['aks nodepool scale'] = """
Expand Down
17 changes: 17 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
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_NODE_OS_CHANNEL_NODE_IMAGE,
CONST_NODE_OS_CHANNEL_NONE,
Expand Down Expand Up @@ -157,6 +159,7 @@
validate_pod_identity_resource_name,
validate_pod_identity_resource_namespace,
validate_pod_subnet_id,
validate_pod_ip_allocation_mode,
validate_priority,
validate_sku_tier,
validate_snapshot_id,
Expand Down Expand Up @@ -224,6 +227,10 @@
CONST_GPU_INSTANCE_PROFILE_MIG4_G,
CONST_GPU_INSTANCE_PROFILE_MIG7_G,
]
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 @@ -583,6 +590,11 @@ 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),
validator=validate_pod_ip_allocation_mode,
)
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 @@ -1269,6 +1281,11 @@ 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),
validator=validate_pod_ip_allocation_mode,
)
c.argument("enable_node_public_ip", action="store_true")
c.argument("node_public_ip_prefix_id")
c.argument(
Expand Down
12 changes: 12 additions & 0 deletions src/aks-preview/azext_aks_preview/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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,
)
from azext_aks_preview._helpers import _fuzzy_match
from knack.log import get_logger
Expand Down Expand Up @@ -298,6 +300,16 @@ def validate_user(namespace):
"--user can only be clusterUser or clusterMonitoringUser")


def validate_pod_ip_allocation_mode(namespace):
Comment thread
nairashu marked this conversation as resolved.
Outdated
"""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_vnet_subnet_id(namespace):
_validate_subnet_id(namespace.vnet_subnet_id, "--vnet-subnet-id")

Expand Down
30 changes: 30 additions & 0 deletions src/aks-preview/azext_aks_preview/agentpool_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ def get_enable_artifact_streaming(self) -> bool:
enable_artifact_streaming = self.agentpool.artifact_streaming_profile.enabled
return enable_artifact_streaming

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:
Comment thread
nairashu marked this conversation as resolved.
Outdated
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_ssh_access(self) -> Union[str, None]:
"""Obtain the value of ssh_access.
"""
Expand Down Expand Up @@ -606,6 +625,15 @@ def set_up_skip_gpu_driver_install(self, agentpool: AgentPool) -> AgentPool:
agentpool.gpu_profile.install_gpu_driver = False
return agentpool

def set_up_pod_ip_allocation_mode(self, agentpool: AgentPool) -> AgentPool:
"""Set up pod ip allocation mode for 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_preview(self) -> AgentPool:
"""The overall controller used to construct the preview AgentPool profile.

Expand Down Expand Up @@ -635,6 +663,8 @@ def construct_agentpool_profile_preview(self) -> AgentPool:
agentpool = self.set_up_skip_gpu_driver_install(agentpool)
# set up agentpool ssh access
agentpool = self.set_up_ssh_access(agentpool)
# set up agentpool pod ip allocation mode
agentpool = self.set_up_pod_ip_allocation_mode(agentpool)
# DO NOT MOVE: keep this at the bottom, restore defaults
agentpool = self._restore_defaults_in_agentpool(agentpool)
return agentpool
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,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 @@ -1142,6 +1143,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