Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
c7f9c66
Adding azure container storage support to az aks preview extension
mukhoakash Sep 30, 2023
2b42cb4
Fixes and restructuring
mukhoakash Oct 2, 2023
2b3a10d
Design change to call the azure container storage installation from M…
mukhoakash Oct 5, 2023
93be0fb
Missed out a couple of changes
mukhoakash Oct 5, 2023
fdf93ec
Merge branch 'main' of github.com:Azure/azure-cli-extensions into acs…
mukhoakash Oct 5, 2023
f5b860a
More fixes to the cli logic
mukhoakash Oct 9, 2023
fb95dc5
Merge branch 'main' of github.com:Azure/azure-cli-extensions into acs…
mukhoakash Oct 9, 2023
3194da7
Adding history and bumping the version
mukhoakash Oct 9, 2023
8daa9b6
Lint fixes and some more changes
mukhoakash Oct 9, 2023
a9923f9
Lint error fixes
mukhoakash Oct 9, 2023
c0daa32
Adding help text for the azure container storage params
mukhoakash Oct 9, 2023
32e9eb6
Lint fixes and some final logic changes
mukhoakash Oct 11, 2023
c3978af
Test cases for enable and disable azure container storage for aks cre…
mukhoakash Oct 11, 2023
5717138
Merge branch 'main' of github.com:Azure/azure-cli-extensions into acs…
mukhoakash Oct 11, 2023
f8fd49d
Fixing a bug
mukhoakash Oct 11, 2023
3263793
Adding help for --storage-pool-name
mukhoakash Oct 11, 2023
a262a6d
Reverting some testing changes
mukhoakash Oct 11, 2023
3b71064
Review comments and unittest cases added
mukhoakash Oct 11, 2023
f910bc9
Lint fixes
mukhoakash Oct 11, 2023
86a4ce2
Moving the helper functions to a new file
mukhoakash Oct 11, 2023
c2f057a
Test case compilation fixes
mukhoakash Oct 11, 2023
ed79001
Lint and test fixes
mukhoakash Oct 11, 2023
9c51248
Adding try catch to the delete operation and fixing a test case
mukhoakash Oct 11, 2023
296039d
Small bug fix in the test code
mukhoakash Oct 11, 2023
bad5c9e
Test fix
mukhoakash Oct 11, 2023
102598c
Small fixes and indentation fixes
mukhoakash Oct 11, 2023
8cb95b0
Some compilation fix
mukhoakash Oct 11, 2023
fa1068f
Removing extension add to validate if tests run
mukhoakash Oct 11, 2023
7e6fc88
Fixing the error message
mukhoakash Oct 13, 2023
29a2a8b
Introducing extension add in test run
mukhoakash Oct 13, 2023
f3b9343
Removing unwanted dependent resource providers since ManagedClusters …
mukhoakash Oct 14, 2023
2b94a54
Marking azurecontainerstorage test for bypass
mukhoakash Oct 14, 2023
a6f40ca
Fix lint issue
mukhoakash Oct 14, 2023
fa7cc4e
Merge branch 'main' of github.com:Azure/azure-cli-extensions into acs…
mukhoakash Oct 14, 2023
8bae3ca
Adding the size of the Large response from index url. Also, removing …
mukhoakash Oct 16, 2023
f9c91fd
Add recording for test_aks_create_with_azurecontainerstorage and comm…
mukhoakash Oct 16, 2023
8a86fe9
Introducing the test once again
mukhoakash Oct 16, 2023
6949be3
Revert "Introducing the test once again"
mukhoakash Oct 16, 2023
f742701
Merge branch 'main' of github.com:Azure/azure-cli-extensions into acs…
mukhoakash Oct 16, 2023
8bda8f7
Review comments
mukhoakash Oct 16, 2023
52272d9
Adding a validator to ensure elastic san storagepools are atleast 1 Ti
mukhoakash Oct 16, 2023
a19da97
Fix compile issue
mukhoakash Oct 16, 2023
8655c6f
Fix error statement
mukhoakash Oct 16, 2023
6d031c4
Improving install time delay for role assignment and adding relevant …
mukhoakash Oct 16, 2023
58cda5f
Remove --storage-pool-type and use --enable-azure-container-storage i…
mukhoakash Oct 18, 2023
d07bf68
Fixing the empty space after log lines. Fix a compile issue
mukhoakash Oct 18, 2023
25281eb
Merge branch 'main' of github.com:Azure/azure-cli-extensions into acs…
mukhoakash Oct 18, 2023
c5cb1ee
Moving prompt to start of disable. Fix a test
mukhoakash Oct 18, 2023
9914bc5
Small fix
mukhoakash Oct 18, 2023
52aa0dc
Fix a constant typo
mukhoakash Oct 18, 2023
60d60b6
Fixing some lint issues
mukhoakash Oct 18, 2023
4d8d9a5
Fixing an indentation issue
mukhoakash Oct 18, 2023
ac95736
Formatting fix
mukhoakash Oct 18, 2023
d451aec
Updating the param in live test
mukhoakash Oct 18, 2023
4e0e320
Changing exception to logger.error
mukhoakash Oct 18, 2023
f5789c2
Adding the temp local disk value
mukhoakash Oct 19, 2023
29f77dd
Removing unused param
mukhoakash Oct 19, 2023
711ee46
Changing exceptions to logger in install call
mukhoakash Oct 19, 2023
a8c5201
Review comment addressed
mukhoakash Oct 19, 2023
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 @@ -11,6 +11,10 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
0.5.162
+++++++
* Add option `--enable-azure-container-storage` and supporting options `--storage-pool-name`, `--storage-pool-type`, `--storage-pool-sku`, `--storage-pool-size` for `az aks create` and `az aks update`. `az aks update` also supports `--azure-container-storage-nodepools` option.
Comment thread
mukhoakash marked this conversation as resolved.
Outdated
* Add option `--disable-azure-container-storage` to `az aks create` and `az aks update`.

0.5.161
+++++++
Expand Down
63 changes: 62 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,21 @@
tags_type,
zones_type,
)
from azure.cli.core.profiles import ResourceType
from azext_aks_preview.azurecontainerstorage._consts import (
CONST_STORAGE_POOL_TYPE_AZURE_DISK,
CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK,
CONST_STORAGE_POOL_TYPE_ELASTIC_SAN,
CONST_STORAGE_POOL_SKU_PREMIUM_LRS,
CONST_STORAGE_POOL_SKU_STANDARD_LRS,
CONST_STORAGE_POOL_SKU_STANDARDSSD_LRS,
CONST_STORAGE_POOL_SKU_ULTRASSD_LRS,
CONST_STORAGE_POOL_SKU_PREMIUM_ZRS,
CONST_STORAGE_POOL_SKU_PREMIUMV2_ZRS,
CONST_STORAGE_POOL_SKU_STANDARDSSD_ZRS,
CONST_STORAGE_POOL_OPTION_NVME,
CONST_STORAGE_POOL_OPTION_TEMP,
CONST_STORAGE_POOL_DEFAULT_SIZE,
)
from knack.arguments import CLIArgumentType

# candidates for enumeration
Expand Down Expand Up @@ -257,6 +271,29 @@
CONST_AZURE_SERVICE_MESH_INGRESS_MODE_INTERNAL,
]

# azure container storage

storage_pool_types = [
CONST_STORAGE_POOL_TYPE_AZURE_DISK,
CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK,
CONST_STORAGE_POOL_TYPE_ELASTIC_SAN,
]

storage_pool_skus = [
CONST_STORAGE_POOL_SKU_PREMIUM_LRS,
CONST_STORAGE_POOL_SKU_STANDARD_LRS,
CONST_STORAGE_POOL_SKU_STANDARDSSD_LRS,
CONST_STORAGE_POOL_SKU_ULTRASSD_LRS,
CONST_STORAGE_POOL_SKU_PREMIUM_ZRS,
CONST_STORAGE_POOL_SKU_PREMIUMV2_ZRS,
CONST_STORAGE_POOL_SKU_STANDARDSSD_ZRS,
]

storage_pool_options = [
CONST_STORAGE_POOL_OPTION_NVME,
CONST_STORAGE_POOL_OPTION_TEMP,
]


def load_arguments(self, _):

Expand Down Expand Up @@ -456,6 +493,16 @@ def load_arguments(self, _):
c.argument('grafana_resource_id', validator=validate_grafanaresourceid)
c.argument('enable_windows_recording_rules', action='store_true')
c.argument('enable_cost_analysis', is_preview=True, action='store_true')
# azure container storage
c.argument('enable_azure_container_storage', action='store_true',
help='Flag to enable azure container storage')
c.argument('storage_pool_type', arg_type=get_enum_type(storage_pool_types),
help='set storage pool type for azure container storage')
c.argument('storage_pool_size', type=str, help='set storage pool size for azure container storage')
c.argument('storage_pool_sku', arg_type=get_enum_type(storage_pool_skus),
help='set azure disk type storage pool sku for azure container storage')
c.argument('storage_pool_option', arg_type=get_enum_type(storage_pool_options),
help='set ephemeral disk storage pool option for azure container storage')

with self.argument_context('aks update') as c:
# managed cluster paramerters
Expand Down Expand Up @@ -584,6 +631,20 @@ def load_arguments(self, _):
c.argument('enable_network_observability', action='store_true', is_preview=True, help="enable network observability for cluster")
c.argument('enable_cost_analysis', is_preview=True, action='store_true')
c.argument('disable_cost_analysis', is_preview=True, action='store_true')
# azure container storage
c.argument('enable_azure_container_storage', action='store_true',
help='Flag to enable azure container storage')
c.argument('disable_azure_container_storage', action='store_true',
help='Flag to disable azure container storage')
Comment thread
mukhoakash marked this conversation as resolved.
c.argument('storage_pool_type', arg_type=get_enum_type(storage_pool_types),
help='set storage pool type for azure container storage')
c.argument('storage_pool_size', type=str, help='set storage pool size for azure container storage')
c.argument('storage_pool_sku', arg_type=get_enum_type(storage_pool_skus),
help='set azure disk type storage pool sku for azure container storage')
c.argument('storage_pool_option', arg_type=get_enum_type(storage_pool_options),
help='set ephemeral disk storage pool option for azure container storage')
c.argument('azure_container_storage_nodepools', default='nodepool1',
help='define the comma separated nodepool list to install azure container storage')

with self.argument_context('aks upgrade') as c:
c.argument('kubernetes_version', completer=get_k8s_upgrades_completion_list)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

CONST_STORAGE_POOL_TYPE_AZURE_DISK = "azureDisk"
CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK = "ephemeralDisk"
CONST_STORAGE_POOL_TYPE_ELASTIC_SAN = "elasticSan"
CONST_STORAGE_POOL_SKU_PREMIUM_LRS = "Premium_LRS"
CONST_STORAGE_POOL_SKU_STANDARD_LRS = "Standard_LRS"
CONST_STORAGE_POOL_SKU_STANDARDSSD_LRS = "StandardSSD_LRS"
CONST_STORAGE_POOL_SKU_ULTRASSD_LRS = "UltraSSD_LRS"
CONST_STORAGE_POOL_SKU_PREMIUM_ZRS = "Premium_ZRS"
CONST_STORAGE_POOL_SKU_PREMIUMV2_ZRS = "PremiumV2_LRS"
CONST_STORAGE_POOL_SKU_STANDARDSSD_ZRS = "StandardSSD_ZRS"
CONST_STORAGE_POOL_OPTION_NVME = "LsV2"
CONST_STORAGE_POOL_OPTION_TEMP = "temp"
CONST_STORAGE_POOL_NAME_PREFIX = "mypool-"
CONST_STORAGE_POOL_DEFAULT_SIZE = "512Gi"
CONST_EXT_INSTALLATION_NAME = "azurecontainerstorage"
CONST_ACSTOR_K8S_EXTENSION_NAME = "microsoft.azstor"

CONST_K8S_EXTENSION_NAME = "k8s-extension"
CONST_K8S_EXTENSION_CLIENT_FACTORY_MOD_NAME = "azext_k8s_extension._client_factory"
CONST_K8S_EXTENSION_CUSTOM_MOD_NAME = "azext_k8s_extension.custom"

CONST_STORAGE_POOL_RANDOM_LENGTH = 7
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azext_aks_preview.azurecontainerstorage._consts import (
CONST_STORAGE_POOL_TYPE_AZURE_DISK,
CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK,
)

from azure.cli.core.azclierror import (
ArgumentUsageError,
InvalidArgumentValueError,
MutuallyExclusiveArgumentError,
)

import re


def validate_azure_container_storage_params(
Comment thread
mukhoakash marked this conversation as resolved.
enable_azure_container_storage,
disable_azure_container_storage,
storage_pool_name,
storage_pool_type,
storage_pool_sku,
storage_pool_option,
storage_pool_size,
):
if enable_azure_container_storage and disable_azure_container_storage:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Cannot set --enable-azure-container-storage '
'and --disable-azure-container-storage together.'
)

if disable_azure_container_storage:
_validate_disable_azure_container_storage_params(
storage_pool_name,
storage_pool_type,
storage_pool_sku,
storage_pool_option,
storage_pool_size,
)

elif enable_azure_container_storage:
_validate_enable_azure_container_storage_params(
storage_pool_name,
storage_pool_type,
storage_pool_sku,
storage_pool_option,
storage_pool_size,
)


def _validate_disable_azure_container_storage_params(
storage_pool_name,
storage_pool_type,
storage_pool_sku,
storage_pool_option,
storage_pool_size,
):
if storage_pool_name is not None:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Cannot define --storage-pool-name value '
'when --disable-azure-container-storage is set.'
)

if storage_pool_type is not None:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Cannot define --storage-pool-type value '
'when --disable-azure-container-storage is set.'
)

if storage_pool_sku is not None:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Cannot define --storage-pool-sku value '
'when --disable-azure-container-storage is set.'
)

if storage_pool_size is not None:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Cannot define --storage-pool-size value '
'when --disable-azure-container-storage is set.'
)

if storage_pool_option is not None:
raise MutuallyExclusiveArgumentError(
'Conflicting flags. Cannot define --storage-pool-option value '
'when --disable-azure-container-storage is set.'
)


def _validate_enable_azure_container_storage_params(
storage_pool_name,
storage_pool_type,
storage_pool_sku,
storage_pool_option,
storage_pool_size,
):
if storage_pool_name is not None:
pattern = r'[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
is_pool_name_valid = re.fullmatch(pattern, storage_pool_name)
if not is_pool_name_valid:
raise InvalidArgumentValueError(
"Invalid --storage-pool-name values. "
"Accepted values are lowercase alphanumeric characters, "
"'-' or '.', and must start and end with an alphanumeric character.")

if storage_pool_type != CONST_STORAGE_POOL_TYPE_AZURE_DISK and \
storage_pool_sku is not None:
raise ArgumentUsageError('Cannot set --storage-pool-sku when --storage-pool-type is not azureDisk')

if storage_pool_type != CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK and \
storage_pool_option is not None:
raise ArgumentUsageError('Cannot set --storage-pool-option when --storage-pool-type is not ephemeralDisk')

if storage_pool_size is not None:
pattern = r'^\d+(?:Gi|Ti)$'
match = re.match(pattern, storage_pool_size)
if match is None:
raise ArgumentUsageError(
'Value for --storage-pool-size should be defined '
'with size followed by Gi or Ti. e.g. 512Gi or 2Ti'
)
Loading