forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[k8s-extension] Release Public Preview Version v0.2.0 (Azure#3164)
- Loading branch information
1 parent
83c6d3d
commit 4413a46
Showing
37 changed files
with
4,472 additions
and
2 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains 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 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,35 @@ | ||
.. :changelog: | ||
Release History | ||
=============== | ||
|
||
0.2.0 | ||
++++++++++++++++++ | ||
|
||
* Refactor for clear separation of extension-type specific customizations | ||
* OpenServiceMesh customization. | ||
* Fix clusterType of Microsoft.ResourceConnector resource | ||
* Update clusterType validation to allow 'appliances' | ||
* Update identity creation to use the appropriate parent resource's type and api-version | ||
* Throw error if cluster type is not one of the 3 supported types | ||
* Rename azuremonitor-containers extension type to microsoft.azuremonitor.containers | ||
* Move CLI errors to non-deprecated error types | ||
* Remove support for update | ||
|
||
0.1.3 | ||
++++++++++++++++++ | ||
|
||
* Customization for microsoft.openservicemesh | ||
|
||
0.1.2 | ||
++++++++++++++++++ | ||
|
||
* Add support for Arc Appliance cluster type | ||
|
||
0.1.1 | ||
++++++++++++++++++ | ||
* Add support for microsoft-azure-defender extension type | ||
|
||
0.1.0 | ||
++++++++++++++++++ | ||
* Initial release. |
This file contains 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,59 @@ | ||
Microsoft Azure CLI 'k8s-extension' Extension | ||
============================================= | ||
|
||
This package is for the 'k8s-extension' extension. | ||
i.e. 'az k8s-extension' | ||
|
||
### How to use ### | ||
Install this extension using the below CLI command | ||
``` | ||
az extension add --name k8s-extension | ||
``` | ||
|
||
### Included Features | ||
#### Kubernetes Extensions: | ||
Kubernetes Extensions: [more info](https://docs.microsoft.com/en-us/azure/kubernetessconfiguration/)\ | ||
*Examples:* | ||
|
||
##### Create a KubernetesExtension | ||
``` | ||
az k8s-extension create \ | ||
--resource-group groupName \ | ||
--cluster-name clusterName \ | ||
--cluster-type clusterType \ | ||
--name extensionName \ | ||
--extension-type extensionType \ | ||
--scope scopeType \ | ||
--release-train releaseTrain \ | ||
--version versionNumber \ | ||
--auto-upgrade-minor-version autoUpgrade \ | ||
--configuration-settings exampleSetting=exampleValue \ | ||
``` | ||
|
||
##### Get a KubernetesExtension | ||
``` | ||
az k8s-extension show \ | ||
--resource-group groupName \ | ||
--cluster-name clusterName \ | ||
--cluster-type clusterType \ | ||
--name extensionName | ||
``` | ||
|
||
##### Delete a KubernetesExtension | ||
``` | ||
az k8s-extension delete \ | ||
--resource-group groupName \ | ||
--cluster-name clusterName \ | ||
--cluster-type clusterType \ | ||
--name extensionName | ||
``` | ||
|
||
##### List all KubernetesExtension of a cluster | ||
``` | ||
az k8s-extension list \ | ||
--resource-group groupName \ | ||
--cluster-name clusterName \ | ||
--cluster-type clusterType | ||
``` | ||
|
||
If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. |
This file contains 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,32 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core import AzCommandsLoader | ||
|
||
from azext_k8s_extension._help import helps # pylint: disable=unused-import | ||
|
||
|
||
class K8sExtensionCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
from azure.cli.core.commands import CliCommandType | ||
from azext_k8s_extension._client_factory import cf_k8s_extension | ||
k8s_extension_custom = CliCommandType( | ||
operations_tmpl='azext_k8s_extension.custom#{}', | ||
client_factory=cf_k8s_extension) | ||
super(K8sExtensionCommandsLoader, self).__init__(cli_ctx=cli_ctx, | ||
custom_command_type=k8s_extension_custom) | ||
|
||
def load_command_table(self, args): | ||
from azext_k8s_extension.commands import load_command_table | ||
load_command_table(self, args) | ||
return self.command_table | ||
|
||
def load_arguments(self, command): | ||
from azext_k8s_extension._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = K8sExtensionCommandsLoader |
This file contains 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,31 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
from azure.cli.core.profiles import ResourceType | ||
|
||
|
||
def cf_k8s_extension(cli_ctx, *_): | ||
from azext_k8s_extension.vendored_sdks import SourceControlConfigurationClient | ||
return get_mgmt_service_client(cli_ctx, SourceControlConfigurationClient) | ||
|
||
|
||
def cf_k8s_extension_operation(cli_ctx, _): | ||
return cf_k8s_extension(cli_ctx).extensions | ||
|
||
|
||
def cf_resource_groups(cli_ctx, subscription_id=None): | ||
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, | ||
subscription_id=subscription_id).resource_groups | ||
|
||
|
||
def cf_resources(cli_ctx, subscription_id=None): | ||
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, | ||
subscription_id=subscription_id).resources | ||
|
||
|
||
def cf_log_analytics(cli_ctx, subscription_id=None): | ||
from azure.mgmt.loganalytics import LogAnalyticsManagementClient # pylint: disable=no-name-in-module | ||
return get_mgmt_service_client(cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id) |
This file contains 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,8 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
EXTENSION_NAME = 'k8s-extension' | ||
VERSION = "0.2.0" |
This file contains 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,24 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from collections import OrderedDict | ||
|
||
|
||
def k8s_extension_list_table_format(results): | ||
return [__get_table_row(result) for result in results] | ||
|
||
|
||
def k8s_extension_show_table_format(result): | ||
return __get_table_row(result) | ||
|
||
|
||
def __get_table_row(result): | ||
return OrderedDict([ | ||
('name', result['name']), | ||
('extensionType', result['extensionType']), | ||
('version', result['version']), | ||
('installState', result['installState']), | ||
('lastModifiedTime', result['lastModifiedTime']) | ||
]) |
This file contains 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,39 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from knack.help_files import helps # pylint: disable=unused-import | ||
import azext_k8s_extension._consts as consts | ||
|
||
|
||
helps[f'{consts.EXTENSION_NAME}'] = """ | ||
type: group | ||
short-summary: Commands to manage K8s-extensions. | ||
""" | ||
|
||
helps[f'{consts.EXTENSION_NAME} create'] = """ | ||
type: command | ||
short-summary: Create a K8s-extension. | ||
""" | ||
|
||
helps[f'{consts.EXTENSION_NAME} list'] = """ | ||
type: command | ||
short-summary: List K8s-extensions. | ||
""" | ||
|
||
helps[f'{consts.EXTENSION_NAME} delete'] = """ | ||
type: command | ||
short-summary: Delete a K8s-extension. | ||
""" | ||
|
||
helps[f'{consts.EXTENSION_NAME} show'] = """ | ||
type: command | ||
short-summary: Show details of a K8s-extension. | ||
""" | ||
|
||
helps[f'{consts.EXTENSION_NAME} update'] = """ | ||
type: command | ||
short-summary: Update a K8s-extension. | ||
""" |
This file contains 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,75 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core.commands.parameters import ( | ||
get_enum_type, | ||
get_three_state_flag, | ||
tags_type | ||
) | ||
from azure.cli.core.commands.validators import get_default_location_from_resource_group | ||
import azext_k8s_extension._consts as consts | ||
|
||
from azext_k8s_extension.action import ( | ||
AddConfigurationSettings, | ||
AddConfigurationProtectedSettings | ||
) | ||
|
||
|
||
def load_arguments(self, _): | ||
with self.argument_context(consts.EXTENSION_NAME) as c: | ||
c.argument('tags', tags_type) | ||
c.argument('location', | ||
validator=get_default_location_from_resource_group) | ||
c.argument('name', | ||
options_list=['--name', '-n'], | ||
help='Name of the extension instance') | ||
c.argument('extension_type', | ||
help='Name of the extension type.') | ||
c.argument('cluster_name', | ||
options_list=['--cluster-name', '-c'], | ||
help='Name of the Kubernetes cluster') | ||
c.argument('cluster_type', | ||
arg_type=get_enum_type(['connectedClusters', 'managedClusters', 'appliances']), | ||
help='Specify Arc clusters or AKS managed clusters or Arc appliances.') | ||
c.argument('scope', | ||
arg_type=get_enum_type(['cluster', 'namespace']), | ||
help='Specify the extension scope.') | ||
c.argument('auto_upgrade_minor_version', | ||
arg_group="Version", | ||
options_list=['--auto-upgrade-minor-version', '--auto-upgrade'], | ||
arg_type=get_three_state_flag(), | ||
help='Automatically upgrade minor version of the extension instance.') | ||
c.argument('version', | ||
arg_group="Version", | ||
help='Specify the version to install for the extension instance if' | ||
' --auto-upgrade-minor-version is not enabled.') | ||
c.argument('release_train', | ||
arg_group="Version", | ||
help='Specify the release train for the extension type.') | ||
c.argument('configuration_settings', | ||
arg_group="Configuration", | ||
options_list=['--configuration-settings', '--config'], | ||
action=AddConfigurationSettings, | ||
nargs='+', | ||
help='Configuration Settings as key=value pair. Repeat parameter for each setting') | ||
c.argument('configuration_protected_settings', | ||
arg_group="Configuration", | ||
options_list=['--configuration-protected-settings', '--config-protected'], | ||
action=AddConfigurationProtectedSettings, | ||
nargs='+', | ||
help='Configuration Protected Settings as key=value pair. Repeat parameter for each setting') | ||
c.argument('configuration_settings_file', | ||
arg_group="Configuration", | ||
options_list=['--configuration-settings-file', '--config-file'], | ||
help='JSON file path for configuration-settings') | ||
c.argument('configuration_protected_settings_file', | ||
arg_group="Configuration", | ||
options_list=['--configuration-protected-settings-file', '--config-protected-file'], | ||
help='JSON file path for configuration-protected-settings') | ||
c.argument('release_namespace', | ||
help='Specify the namespace to install the extension release.') | ||
c.argument('target_namespace', | ||
help='Specify the target namespace to install to for the extension instance. This' | ||
' parameter is required if extension scope is set to \'namespace\'') |
This file contains 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,37 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import argparse | ||
from azure.cli.core.azclierror import ArgumentUsageError | ||
|
||
|
||
# pylint: disable=protected-access, too-few-public-methods | ||
class AddConfigurationSettings(argparse._AppendAction): | ||
|
||
def __call__(self, parser, namespace, values, option_string=None): | ||
settings = {} | ||
for item in values: | ||
try: | ||
key, value = item.split('=', 1) | ||
settings[key] = value | ||
except ValueError: | ||
raise ArgumentUsageError('Usage error: {} configuration_setting_key=configuration_setting_value'. | ||
format(option_string)) | ||
super(AddConfigurationSettings, self).__call__(parser, namespace, settings, option_string) | ||
|
||
|
||
# pylint: disable=protected-access, too-few-public-methods | ||
class AddConfigurationProtectedSettings(argparse._AppendAction): | ||
|
||
def __call__(self, parser, namespace, values, option_string=None): | ||
prot_settings = {} | ||
for item in values: | ||
try: | ||
key, value = item.split('=', 1) | ||
prot_settings[key] = value | ||
except ValueError: | ||
raise ArgumentUsageError('Usage error: {} configuration_protected_setting_key=' | ||
'configuration_protected_setting_value'.format(option_string)) | ||
super(AddConfigurationProtectedSettings, self).__call__(parser, namespace, prot_settings, option_string) |
This file contains 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,4 @@ | ||
{ | ||
"azext.isPreview": true, | ||
"azext.minCliCoreVersion": "2.15.0" | ||
} |
This file contains 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,26 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: disable=line-too-long | ||
from azure.cli.core.commands import CliCommandType | ||
from azext_k8s_extension._client_factory import (cf_k8s_extension, cf_k8s_extension_operation) | ||
from azext_k8s_extension._format import k8s_extension_list_table_format, k8s_extension_show_table_format | ||
import azext_k8s_extension._consts as consts | ||
|
||
|
||
def load_command_table(self, _): | ||
|
||
k8s_extension_sdk = CliCommandType( | ||
operations_tmpl='azext_k8s_extension.vendored_sdks.operations#K8sExtensionsOperations.{}', | ||
client_factory=cf_k8s_extension) | ||
|
||
with self.command_group(consts.EXTENSION_NAME, k8s_extension_sdk, client_factory=cf_k8s_extension_operation, | ||
is_preview=True) \ | ||
as g: | ||
g.custom_command('create', 'create_k8s_extension') | ||
g.custom_command('update', 'update_k8s_extension') | ||
g.custom_command('delete', 'delete_k8s_extension', confirmation=True) | ||
g.custom_command('list', 'list_k8s_extension', table_transformer=k8s_extension_list_table_format) | ||
g.custom_show_command('show', 'show_k8s_extension', table_transformer=k8s_extension_show_table_format) |
Oops, something went wrong.