-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[aks-preview] Add --enable-backup to az aks create and az aks update #9897
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
Draft
anshulahuja98
wants to merge
7
commits into
Azure:main
Choose a base branch
from
anshulahuja98:feat/aks-enable-backup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9a3562
[aks-preview] Add --enable-backup to az aks create and az aks update
d1bb93b
[aks-preview] HISTORY: note --enable-backup under Pending
08bc672
[aks-preview] aks_backup: align continuation indent + silence too-man…
0b138f9
Merge branch 'main' into feat/aks-enable-backup
anshulahuja98 e2739c7
[aks-preview] _params: note backup-strategy enum mirrors dataprotection
237444b
[aks-preview] Address CI lint feedback
2ce8293
[aks-preview] Extract backup-strategy enum into a shared constant
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| """Helpers that delegate AKS backup enablement to the dataprotection CLI extension. | ||
|
|
||
| The actual orchestration (vault, policy, storage account, extension install, | ||
| trusted access, role assignments, backup instance) lives in the | ||
| ``dataprotection`` extension. This module is a thin shim that: | ||
|
|
||
| * loads that extension's path lazily (so ``az aks`` works without it), | ||
| * raises an actionable error if the extension is not installed, | ||
| * derives the AKS datasource ARM id from the resource group + cluster name. | ||
| """ | ||
|
|
||
| from azure.cli.core.azclierror import UnknownError | ||
| from azure.cli.core.commands.client_factory import get_subscription_id | ||
|
|
||
|
|
||
| def enable_aks_backup(cmd, resource_group_name, cluster_name, # pylint: disable=too-many-positional-arguments | ||
| backup_strategy, backup_configuration_file, yes): | ||
| """Enable Azure Backup for an AKS cluster by delegating to the | ||
| ``dataprotection`` extension. | ||
|
|
||
| Raises ``UnknownError`` if the extension is not installed. | ||
| """ | ||
| try: | ||
| from azure.cli.core.extension.operations import add_extension_to_path | ||
| add_extension_to_path("dataprotection") | ||
| from azext_dataprotection.manual.aks.aks_helper import ( | ||
| dataprotection_enable_backup_helper, | ||
| ) | ||
| except ImportError: | ||
| raise UnknownError( # pylint: disable=raise-missing-from | ||
| "Please add CLI extension `dataprotection` to use --enable-backup with " | ||
| "'az aks create' / 'az aks update'.\n" | ||
| "Run command `az extension add --name dataprotection`." | ||
| ) | ||
|
|
||
| subscription_id = get_subscription_id(cmd.cli_ctx) | ||
| datasource_id = ( | ||
| f"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}" | ||
| f"/providers/Microsoft.ContainerService/managedClusters/{cluster_name}" | ||
| ) | ||
| dataprotection_enable_backup_helper( | ||
| cmd, | ||
| datasource_id, | ||
| backup_strategy or "Week", | ||
| backup_configuration_file or {}, | ||
| yes=yes, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about requesting the user's confirmation to install the extension if it hasn't been installed yet?