Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,5 @@
/src/acat @qinqingxu @Sherylueen @yongxin-ms @wh-alice

/src/zones/ @nielsams

/src/vme/ @caoyihua
5 changes: 5 additions & 0 deletions src/service_name.json
Original file line number Diff line number Diff line change
Expand Up @@ -943,5 +943,10 @@
"Command": "az lambda-test",
"AzureServiceName": "LambdaTest",
"URL": "https://learn.microsoft.com/en-us/azure/partner-solutions"
},
{
"Command": "az vme",
"AzureServiceName": "Azure Arc Kubernetes Version Managed Extensions",
"URL": ""
}
]
8 changes: 8 additions & 0 deletions src/vme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

1.0.0b1
++++++
* Initial release.
27 changes: 27 additions & 0 deletions src/vme/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Microsoft Azure CLI 'vme' Extension
==========================================

This package is for the 'vme' extension.
i.e. 'az vme'

### How to use ###
Install this extension using the below CLI command
```
az extension add --name vme
```

### Included Features
#### Install version managed extensions with default configurations
```
az vme install --resource-group my-rg --name my-cluster --include all
```

#### Uninstall version managed extensions
```
az vme uninstall --resource-group my-rg --name my-cluster --include all
```

#### Check version managed extensions' upgrade status
```
az vme upgrade --resource-group my-rg --name my-cluster --wait
```
34 changes: 34 additions & 0 deletions src/vme/azext_vme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# --------------------------------------------------------------------------------------------
# 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 ._help import helps # pylint: disable=unused-import


class VmeCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_vme._client_factory import cf_vme

vme_custom = CliCommandType(
operations_tmpl='azext_vme.custom#{}',
client_factory=cf_vme)
super().__init__(cli_ctx=cli_ctx, custom_command_type=vme_custom)

def load_command_table(self, args):
from azext_vme.commands import load_command_table

load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_vme._params import load_arguments

load_arguments(self, command)


COMMAND_LOADER_CLS = VmeCommandsLoader
22 changes: 22 additions & 0 deletions src/vme/azext_vme/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# --------------------------------------------------------------------------------------------
# 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_vme(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)


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_deployments(cli_ctx, subscription_id=None):
return get_mgmt_service_client(
cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id
).deployments
49 changes: 49 additions & 0 deletions src/vme/azext_vme/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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=line-too-long
helps['vme'] = """
type: group
short-summary: Commands to manage version managed extensions on connected kubernetes clusters.
"""

helps['vme install'] = """
type: command
short-summary: Install version managed extensions.
examples:
- name: Install all version managed extensions
text: |-
az vme install --resource-group my-resource-group --cluster-name my-cluster --include all
- name: Install specific version managed extension
text: |-
az vme install --resource-group my-resource-group --cluster-name my-cluster --include microsoft.azure.secretstore
- name: Enable feature flag and then install specific version managed extension
text: |-
az vme install --resource-group my-resource-group --cluster-name my-cluster --include microsoft.arc.containerstorage --kube-config /path/to/kubeconfig.yaml --kube-context my-context
"""

helps['vme uninstall'] = """
type: command
short-summary: Uninstall version managed extensions.
examples:
- name: Uninstall all version managed extensions
text: |-
az vme uninstall --resource-group my-resource-group --cluster-name my-cluster --include all
- name: Uninstall specific version managed extension
text: |-
az vme uninstall --resource-group my-resource-group --cluster-name my-cluster --include microsoft.azure.secretstore
"""

helps['vme upgrade'] = """
type: command
short-summary: Check version managed extensions' upgrade status.
examples:
- name: Check version managed extensions' upgrade status
text: |-
az vme upgrade --resource-group my-resource-group --cluster-name my-cluster --wait
"""
94 changes: 94 additions & 0 deletions src/vme/azext_vme/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# --------------------------------------------------------------------------------------------
# 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.parameters import get_enum_type
from .consts import IncludedExtensionTypes
from .action import AddIncludedExtensionTypes


def load_arguments(self, _):

with self.argument_context('vme upgrade') as c:
c.argument(
'resource_group',
options_list=['--resource-group', '-g'],
help='Name of the resource group'
)
c.argument(
'cluster_name',
options_list=['--cluster-name', '-c'],
help='Name of the Kubernetes cluster'
)
c.argument(
"kube_config",
options_list=["--kube-config"],
help="Path to the kube config file. Optional if the cluster has the feature flag enabled or the current Kubernetes config/context is set to this cluster.",
)
c.argument(
"kube_context",
options_list=["--kube-context"],
help="Kube context from current machine. Optional if the cluster has the feature flag enabled or the current Kubernetes config/context is set to this cluster.",
)
c.argument(
"wait",
options_list=["--wait"],
help="Wait for the bundle upgrade to finish.",
)
c.argument(
"timeout",
options_list=["--timeout"],
help="Time required (in seconds) for the bundle upgrade to finish.",
)

with self.argument_context('vme install') as c:
c.argument(
'resource_group',
options_list=['--resource-group', '-g'],
help='Name of the resource group'
)
c.argument(
'cluster_name',
options_list=['--cluster-name', '-c'],
help='Name of the Kubernetes cluster'
)
c.argument(
'include_extension_types',
options_list=['--include', '-i'],
action=AddIncludedExtensionTypes,
nargs="+",
help='Extension types to be installed.',
arg_type=get_enum_type(IncludedExtensionTypes),
)
c.argument(
"kube_config",
options_list=["--kube-config"],
help="Path to the kube config file. Optional if the cluster has the feature flag enabled or the current Kubernetes config/context is set to this cluster.",
)
c.argument(
"kube_context",
options_list=["--kube-context"],
help="Kube context from current machine. Optional if the cluster has the feature flag enabled or the current Kubernetes config/context is set to this cluster.",
)

with self.argument_context('vme uninstall') as c:
c.argument(
'resource_group',
options_list=['--resource-group', '-g'],
help='Name of the resource group'
)
c.argument(
'cluster_name',
options_list=['--cluster-name', '-c'],
help='Name of the Kubernetes cluster'
)
c.argument(
'include_extension_types',
options_list=['--include', '-i'],
action=AddIncludedExtensionTypes,
nargs="+",
help='Extension types to be uninstalled.',
arg_type=get_enum_type(IncludedExtensionTypes),
)
24 changes: 24 additions & 0 deletions src/vme/azext_vme/action.py
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 __future__ import annotations

import argparse
from typing import Any


# pylint: disable=protected-access
class AddIncludedExtensionTypes(argparse._AppendAction):
def __call__(
self,
parser: argparse.ArgumentParser,
namespace: argparse.Namespace,
values: Any,
option_string: str | None = None,
) -> None:
include_types = getattr(namespace, self.dest, None)
if include_types is None:
include_types = []
include_types.extend(values)
setattr(namespace, self.dest, include_types)
4 changes: 4 additions & 0 deletions src/vme/azext_vme/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.70.0"
}
13 changes: 13 additions & 0 deletions src/vme/azext_vme/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# 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

def load_command_table(self, _):

with self.command_group('vme') as g:
g.custom_command('upgrade', 'upgrade_vme')
g.custom_command('install', 'install_vme')
g.custom_command('uninstall', 'uninstall_vme')
42 changes: 42 additions & 0 deletions src/vme/azext_vme/consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --------------------------------------------------------------------------------------------
# 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

HELM_MCR_URL = "mcr.microsoft.com/azurearck8s/helm"
HELM_VERSION = "v3.12.2"
CONNECTEDCLUSTER_RP = "Microsoft.Kubernetes"
CONNECTEDCLUSTER_TYPE = "connectedClusters"
ArcAgentProfile = "arcAgentProfile"
ArcAgentAutoUpgrade = "agentAutoUpgrade"
ArcAgentryConfigurations = "arcAgentryConfigurations"
ArcAgentryBundleFeatureName = "extensionSets"
ArcAgentryBundleSettingsName = "versionManagedExtensions"
ARC_UPDATE_PREFIX = "Arc-Update-"
AGENT_VERSION_TAG = "AgentVersion"
FAILED = "Failed"
SUCCEEDED = "Succeeded"
CANCELLED = "Cancelled"
Bundle_FeatureFlag_NotEnabled = "Bundle feature flag is not enabled."
UPGRADE_IN_PROGRESS_MSG = "Version managed extensions upgrade is in progress …"
UPGRADE_SUCCEEDED_MSG = "Version managed extensions upgrade completed!"
UPGRADE_FAILED_MSG = "Version managed extensions upgrade failed. Error: "
UPGRADE_CANCELED_MSG = "Version managed extensions upgrade is canceled."
UPGRADE_NOTSTARTED_MSG = "Waiting for version managed extensions upgrade to start …"
UPGRADE_TIMEOUT_MSG = """
Error: version managed extensions upgrade could not start in {0} seconds. Check out common issues here: <url>
"""
UPGRADE_CHECK_INTERVAL = 5
BundleExtensionTypes = [
"microsoft.arc.containerstorage",
"microsoft.azure.secretstore"
]

BundleExtensionNames = {
"microsoft.arc.containerstorage": "azure-arc-containerstorage",
"microsoft.azure.secretstore": "azure-secret-store",
}

IncludedExtensionTypes = BundleExtensionTypes + ["all"]
Loading
Loading