Skip to content

Commit

Permalink
{AKS} Integrate azuredisk csi driver version to cli (#4865)
Browse files Browse the repository at this point in the history
  • Loading branch information
mukhoakash authored May 30, 2022
1 parent bb08dd8 commit 85ef8a1
Show file tree
Hide file tree
Showing 11 changed files with 2,126 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

0.5.77
++++++

* Add support to pass csi `disk-driver-version` for `az aks create` and `az aks update`.

0.5.76
++++++

* Add support for Custom CA Trust in `az aks create`, `az aks nodepool add`, `az aks nodepool update`.

0.5.75
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 @@ -83,6 +83,10 @@
CONST_NETWORK_PLUGIN_AZURE = "azure"
CONST_NETWORK_PLUGIN_NONE = "none"

# disk driver versions
CONST_DISK_DRIVER_V1 = "v1"
CONST_DISK_DRIVER_V2 = "v2"

# consts for addons
# http application routing
CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME = "httpApplicationRouting"
Expand Down
6 changes: 6 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@
- name: --disable-disk-driver
type: bool
short-summary: Disable AzureDisk CSI Driver.
- name: --disk-driver-version
type: string
short-summary: Specify AzureDisk CSI Driver version.
- name: --disable-file-driver
type: bool
short-summary: Disable AzureFile CSI Driver.
Expand Down Expand Up @@ -672,6 +675,9 @@
- name: --enable-disk-driver
type: bool
short-summary: Enable AzureDisk CSI Driver.
- name: --disk-driver-version
type: string
short-summary: Specify AzureDisk CSI Driver version.
- name: --disable-disk-driver
type: bool
short-summary: Disable AzureDisk CSI Driver.
Expand Down
5 changes: 5 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_STABLE_UPGRADE_CHANNEL,
CONST_WORKLOAD_RUNTIME_OCI_CONTAINER,
CONST_WORKLOAD_RUNTIME_WASM_WASI,
CONST_DISK_DRIVER_V1,
CONST_DISK_DRIVER_V2,
)
from ._validators import (
validate_acr,
Expand Down Expand Up @@ -132,6 +134,7 @@
# consts for ManagedCluster
load_balancer_skus = [CONST_LOAD_BALANCER_SKU_BASIC, CONST_LOAD_BALANCER_SKU_STANDARD]
network_plugins = [CONST_NETWORK_PLUGIN_KUBENET, CONST_NETWORK_PLUGIN_AZURE, CONST_NETWORK_PLUGIN_NONE]
disk_driver_versions = [CONST_DISK_DRIVER_V1, CONST_DISK_DRIVER_V2]
outbound_types = [
CONST_OUTBOUND_TYPE_LOAD_BALANCER,
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
Expand Down Expand Up @@ -269,6 +272,7 @@ def load_arguments(self, _):
c.argument('enable_fips_image', action='store_true')
c.argument('kubelet_config')
c.argument('linux_os_config')
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
c.argument('disable_disk_driver', arg_type=get_three_state_flag())
c.argument('disable_file_driver', arg_type=get_three_state_flag())
c.argument('disable_snapshot_controller', arg_type=get_three_state_flag())
Expand Down Expand Up @@ -337,6 +341,7 @@ def load_arguments(self, _):
c.argument('gmsa_dns_server')
c.argument('gmsa_root_domain_name')
c.argument('enable_disk_driver', arg_type=get_three_state_flag())
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
c.argument('disable_disk_driver', arg_type=get_three_state_flag())
c.argument('enable_file_driver', arg_type=get_three_state_flag())
c.argument('disable_file_driver', arg_type=get_three_state_flag())
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 @@ -789,6 +789,7 @@ def aks_create(cmd,
enable_ultra_ssd=False,
edge_zone=None,
enable_secret_rotation=False,
disk_driver_version=None,
disable_disk_driver=None,
disable_file_driver=None,
disable_snapshot_controller=None,
Expand Down Expand Up @@ -880,6 +881,7 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
disable_secret_rotation=False,
rotation_poll_interval=None,
enable_disk_driver=None,
disk_driver_version=None,
disable_disk_driver=None,
enable_file_driver=None,
disable_file_driver=None,
Expand Down
21 changes: 20 additions & 1 deletion src/aks-preview/azext_aks_preview/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from azure.cli.core import AzCommandsLoader
from azure.cli.core.azclierror import (
ArgumentUsageError,
AzCLIError,
CLIInternalError,
InvalidArgumentValueError,
Expand All @@ -44,6 +45,7 @@
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
CONST_DISK_DRIVER_V1,
)
from azext_aks_preview._loadbalancer import create_load_balancer_profile
from azext_aks_preview._loadbalancer import (
Expand Down Expand Up @@ -1721,7 +1723,8 @@ def get_disk_driver(self) -> Optional[ManagedClusterStorageProfileDiskCSIDriver]
"""
enable_disk_driver = self.raw_param.get("enable_disk_driver")
disable_disk_driver = self.raw_param.get("disable_disk_driver")
if not enable_disk_driver and not disable_disk_driver:
disk_driver_version = self.raw_param.get("disk_driver_version")
if not enable_disk_driver and not disable_disk_driver and not disk_driver_version:
return None
profile = self.models.ManagedClusterStorageProfileDiskCSIDriver()

Expand All @@ -1731,15 +1734,30 @@ def get_disk_driver(self) -> Optional[ManagedClusterStorageProfileDiskCSIDriver]
"--disable-disk-driver at the same time."
)

if disable_disk_driver and disk_driver_version:
raise ArgumentUsageError(
"The parameter --disable-disk-driver cannot be used "
"when --disk-driver-version is specified.")

if self.decorator_mode == DecoratorMode.UPDATE and disk_driver_version and not enable_disk_driver:
raise ArgumentUsageError(
"Parameter --enable-disk-driver is required "
"when --disk-driver-version is specified during update.")

if self.decorator_mode == DecoratorMode.CREATE:
if disable_disk_driver:
profile.enabled = False
else:
profile.enabled = True
if not disk_driver_version:
disk_driver_version = CONST_DISK_DRIVER_V1
profile.version = disk_driver_version

if self.decorator_mode == DecoratorMode.UPDATE:
if enable_disk_driver:
profile.enabled = True
if disk_driver_version:
profile.version = disk_driver_version
elif disable_disk_driver:
profile.enabled = False

Expand Down Expand Up @@ -2716,6 +2734,7 @@ def check_raw_parameters(self):
'"--enable-oidc-issuer" or '
'"--http-proxy-config" or '
'"--enable-disk-driver" or '
'"--disk-driver-version" or '
'"--disable-disk-driver" or '
'"--enable-file-driver" or '
'"--disable-file-driver" or '
Expand Down
Loading

0 comments on commit 85ef8a1

Please sign in to comment.