Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] support blob csi driver #5027

Merged
merged 13 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Pending
* Enable v2 decorator pattern.
* Fix container name inconsistency for private clusters in kollect command.

0.5.83
+++++++

* Add support for Blob csi driver.

0.5.82
+++++++

Expand Down
9 changes: 9 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-snapshot-controller
type: bool
short-summary: Disable CSI Snapshot Controller.
- name: --enable-blob-driver
type: bool
short-summary: Enable AzureBlob CSI Driver.
- name: --aci-subnet-name
type: string
short-summary: The name of a subnet in an existing VNet into which to deploy the virtual nodes.
Expand Down Expand Up @@ -697,6 +700,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: --tags
type: string
short-summary: The tags of the managed cluster. The managed cluster instance and all resources managed by the cloud provider will be tagged.
Expand Down
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def load_arguments(self, _):
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
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_apiserver_vnet_integration', action='store_true', is_preview=True)
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id, is_preview=True)
Expand Down Expand Up @@ -393,6 +394,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('enable_apiserver_vnet_integration', action='store_true', is_preview=True)
Expand Down
3 changes: 3 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(
disk_driver_version=None,
disable_disk_driver=False,
disable_file_driver=False,
enable_blob_driver=None,
disable_snapshot_controller=False,
enable_apiserver_vnet_integration=False,
apiserver_subnet_id=None,
Expand Down Expand Up @@ -901,6 +902,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_apiserver_vnet_integration=False,
Expand Down
48 changes: 48 additions & 0 deletions src/aks-preview/azext_aks_preview/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
ManagedClusterStorageProfile = TypeVar('ManagedClusterStorageProfile')
ManagedClusterStorageProfileDiskCSIDriver = TypeVar('ManagedClusterStorageProfileDiskCSIDriver')
ManagedClusterStorageProfileFileCSIDriver = TypeVar('ManagedClusterStorageProfileFileCSIDriver')
ManagedClusterStorageProfileBlobCSIDriver = TypeVar('ManagedClusterStorageProfileBlobCSIDriver')
ManagedClusterStorageProfileSnapshotController = TypeVar('ManagedClusterStorageProfileSnapshotController')
ManagedClusterAPIServerAccessProfile = TypeVar('ManagedClusterAPIServerAccessProfile')
Snapshot = TypeVar("Snapshot")
Expand Down Expand Up @@ -180,6 +181,11 @@ def __init__(self, cmd: AzCommandsLoader, resource_type: ResourceType):
resource_type=self.resource_type,
operation_group="managed_clusters",
)
self.ManagedClusterStorageProfileBlobCSIDriver = self.__cmd.get_models(
"ManagedClusterStorageProfileBlobCSIDriver",
resource_type=self.resource_type,
operation_group="managed_clusters",
)
self.ManagedClusterStorageProfileSnapshotController = self.__cmd.get_models(
"ManagedClusterStorageProfileSnapshotController",
resource_type=self.resource_type,
Expand Down Expand Up @@ -1816,6 +1822,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
else:
profile.enabled = False

if self.decorator_mode == DecoratorMode.UPDATE:
if enable_blob_driver:
msg = "Please make sure there are no open-source Blob CSI driver installed before enabling."
cvvz marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -1863,6 +1908,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 Expand Up @@ -2960,6 +3006,8 @@ def check_raw_parameters(self):
'"--disable-disk-driver" or '
'"--enable-file-driver" or '
'"--disable-file-driver" or '
'"--enable-blob-driver" or '
'"--disable-blob-driver" or '
'"--enable-snapshot-controller" or '
'"--disable-snapshot-controller" or '
'"--enable-azure-keyvault-kms" or '
Expand Down
41 changes: 41 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
ManagedClusterStorageProfile = TypeVar('ManagedClusterStorageProfile')
ManagedClusterStorageProfileDiskCSIDriver = TypeVar('ManagedClusterStorageProfileDiskCSIDriver')
ManagedClusterStorageProfileFileCSIDriver = TypeVar('ManagedClusterStorageProfileFileCSIDriver')
ManagedClusterStorageProfileBlobCSIDriver = TypeVar('ManagedClusterStorageProfileBlobCSIDriver')
ManagedClusterStorageProfileSnapshotController = TypeVar('ManagedClusterStorageProfileSnapshotController')
ManagedClusterIngressProfileWebAppRouting = TypeVar("ManagedClusterIngressProfileWebAppRouting")

Expand Down Expand Up @@ -1011,6 +1012,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
else:
profile.enabled = False
cvvz marked this conversation as resolved.
Show resolved Hide resolved

if self.decorator_mode == DecoratorMode.UPDATE:
if enable_blob_driver:
msg = "Please make sure there are 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."
cvvz marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -1056,6 +1096,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