Skip to content

Commit

Permalink
[AKS] az aks create/update: Support Blob CSI driver (Azure#24404)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz authored Oct 26, 2022
1 parent b693fcb commit b2b3fb3
Show file tree
Hide file tree
Showing 8 changed files with 4,752 additions and 4 deletions.
9 changes: 9 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 @@ -413,6 +413,9 @@
- name: --disable-snapshot-controller
type: bool
short-summary: Disable CSI Snapshot Controller.
- name: --enable-blob-driver
type: bool
short-summary: Enable AzureBlob CSI Driver.
- name: --http-proxy-config
type: string
short-summary: HTTP Proxy configuration for this cluster.
Expand Down Expand Up @@ -683,6 +686,12 @@
- name: --disable-snapshot-controller
type: bool
short-summary: Disable CSI Snapshot Controller.
- name: --enable-blob-driver
type: bool
short-summary: Enable AzureBlob CSI Driver.
- name: --disable-blob-driver
type: bool
short-summary: Disable AzureBlob CSI Driver.
- name: --http-proxy-config
type: string
short-summary: HTTP Proxy configuration for this cluster.
Expand Down
3 changes: 3 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 @@ -208,6 +208,7 @@ def load_arguments(self, _):
c.argument('defender_config', validator=validate_defender_config_parameter)
c.argument('disable_disk_driver', action='store_true')
c.argument('disable_file_driver', action='store_true')
c.argument('enable_blob_driver', action='store_true')
c.argument('disable_snapshot_controller', action='store_true')
c.argument('enable_azure_keyvault_kms', action='store_true')
c.argument('azure_keyvault_kms_key_id', validator=validate_azure_keyvault_kms_key_id)
Expand Down Expand Up @@ -298,6 +299,8 @@ def load_arguments(self, _):
c.argument('disable_disk_driver', action='store_true')
c.argument('enable_file_driver', action='store_true')
c.argument('disable_file_driver', action='store_true')
c.argument('enable_blob_driver', action='store_true')
c.argument('disable_blob_driver', action='store_true')
c.argument('enable_snapshot_controller', action='store_true')
c.argument('disable_snapshot_controller', action='store_true')
c.argument('disable_defender', action='store_true', validator=validate_defender_disable_and_enable_parameters)
Expand Down
3 changes: 3 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 @@ -428,6 +428,7 @@ def aks_create(
defender_config=None,
disable_disk_driver=False,
disable_file_driver=False,
enable_blob_driver=None,
disable_snapshot_controller=False,
enable_azure_keyvault_kms=False,
azure_keyvault_kms_key_id=None,
Expand Down Expand Up @@ -545,6 +546,8 @@ def aks_update(
disable_disk_driver=False,
enable_file_driver=False,
disable_file_driver=False,
enable_blob_driver=None,
disable_blob_driver=None,
enable_snapshot_controller=False,
disable_snapshot_controller=False,
enable_azure_keyvault_kms=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
ManagedClusterStorageProfile = TypeVar('ManagedClusterStorageProfile')
ManagedClusterStorageProfileDiskCSIDriver = TypeVar('ManagedClusterStorageProfileDiskCSIDriver')
ManagedClusterStorageProfileFileCSIDriver = TypeVar('ManagedClusterStorageProfileFileCSIDriver')
ManagedClusterStorageProfileBlobCSIDriver = TypeVar('ManagedClusterStorageProfileBlobCSIDriver')
ManagedClusterStorageProfileSnapshotController = TypeVar('ManagedClusterStorageProfileSnapshotController')

# TODO
Expand Down Expand Up @@ -594,6 +595,45 @@ def get_file_driver(self) -> Optional[ManagedClusterStorageProfileFileCSIDriver]

return profile

def get_blob_driver(self) -> Optional[ManagedClusterStorageProfileBlobCSIDriver]:
"""Obtain the value of storage_profile.blob_csi_driver
:return: Optional[ManagedClusterStorageProfileBlobCSIDriver]
"""
enable_blob_driver = self.raw_param.get("enable_blob_driver")
disable_blob_driver = self.raw_param.get("disable_blob_driver")

if enable_blob_driver is None and disable_blob_driver is None:
return None

profile = self.models.ManagedClusterStorageProfileBlobCSIDriver()

if enable_blob_driver and disable_blob_driver:
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-blob-driver and "
"--disable-blob-driver at the same time."
)

if self.decorator_mode == DecoratorMode.CREATE:
if enable_blob_driver:
profile.enabled = True

if self.decorator_mode == DecoratorMode.UPDATE:
if enable_blob_driver:
msg = "Please make sure there is no open-source Blob CSI driver installed before enabling."
if not self.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
profile.enabled = True
elif disable_blob_driver:
msg = (
"Please make sure there are no existing PVs and PVCs "
"that are used by Blob CSI driver before disabling."
)
if not self.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
profile.enabled = False

return profile

def get_snapshot_controller(self) -> Optional[ManagedClusterStorageProfileSnapshotController]:
"""Obtain the value of storage_profile.snapshot_controller
Expand Down Expand Up @@ -642,6 +682,7 @@ def get_storage_profile(self) -> Optional[ManagedClusterStorageProfile]:
profile = self.mc.storage_profile
profile.disk_csi_driver = self.get_disk_driver()
profile.file_csi_driver = self.get_file_driver()
profile.blob_csi_driver = self.get_blob_driver()
profile.snapshot_controller = self.get_snapshot_controller()

return profile
Expand Down
Loading

0 comments on commit b2b3fb3

Please sign in to comment.