Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3cc8452
Kubernetes Data Protection Extension CLI (#173)
Miraj50 Aug 25, 2022
6c56613
{AKS - ARC} fix: Update DCR creation to Clusters resource group inste…
bragi92 Sep 28, 2022
083ed6d
Add self-signed cert to fix PR gate for azureml extension
Sep 27, 2022
0a6208d
adding the api version to the operation definition in the client factory
Sep 29, 2022
2121a2e
Merge pull request #181 from AzureArcForKubernetes/deesharma/exttypes
deeksha345 Sep 29, 2022
9c6835c
bump k8s-extension version to 1.3.6
Sep 29, 2022
1aaef92
Merge pull request #182 from AzureArcForKubernetes/release-1.3.6
deeksha345 Sep 29, 2022
700bee5
adding tests for all 4 extension types calls
Sep 30, 2022
efd86d4
adding to test config file
Sep 30, 2022
8dcef49
updating the api version for extension types to be the correct versio…
Sep 30, 2022
2ecb63a
add test case for flux extension (#184)
bavneetsingh16 Oct 3, 2022
f1c9348
Merge branch 'k8s-extension/public' into deesharma/exttypestests
deeksha345 Oct 5, 2022
5c57791
Merge pull request #183 from AzureArcForKubernetes/deesharma/exttypes…
deeksha345 Oct 5, 2022
84dcc92
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Oct 5, 2022
4ae3aa6
bump k8s-extension version to 1.3.6
Oct 5, 2022
0213a71
bump k8s-extension version to 1.3.6
Oct 6, 2022
a2a8be4
Merge pull request #186 from AzureArcForKubernetes/release-1.3.6
deeksha345 Oct 6, 2022
ef3e79f
adding upstream test for extension types
Oct 17, 2022
eeadb2b
Merge pull request #189 from AzureArcForKubernetes/deesharma/addingex…
deeksha345 Oct 17, 2022
0378ecf
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Oct 17, 2022
929928f
updating history.rst
Oct 17, 2022
374edcf
Merge pull request #190 from AzureArcForKubernetes/release-1.3.6
deeksha345 Oct 18, 2022
5b6b4dc
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Oct 18, 2022
e95cd6e
Merge branch 'k8s-extension/public' into release-1.3.6
Oct 18, 2022
477613d
Merge pull request #191 from AzureArcForKubernetes/release-1.3.6
deeksha345 Oct 18, 2022
cbd30bf
[Dapr] Prompt user for existing Dapr installation during extension cr…
shubham1172 Nov 10, 2022
5d8592e
Merge branch 'main' of github.com:Azure/azure-cli-extensions into rel…
Nov 15, 2022
155fb01
bump k8s-extension version to 1.3.7
Nov 15, 2022
0d74a15
Merge branch 'main' of github.com:Azure/azure-cli-extensions into rel…
Nov 16, 2022
c88e8ef
Merge branch 'main' of github.com:Azure/azure-cli-extensions into rel…
Nov 18, 2022
464cca7
Merge pull request #196 from AzureArcForKubernetes/release-1.3.7
bavneetsingh16 Nov 18, 2022
0487616
[Dapr] Disable applying CRDs during a downgrade (#193)
shubham1172 Nov 28, 2022
d54d6ab
ContainerInsights extension - Add dataCollectionSettings configurati…
ganga1980 Dec 2, 2022
b2f1319
Upgrade Python version from 3.6 to 3.7 (#203)
NarayanThiru Dec 15, 2022
ee8a070
[Dapr] Do not apply CRD hook when version is unchanged or auto-upgrad…
shubham1172 Dec 16, 2022
e054268
add dummy key for amalogs as well
Dec 29, 2022
4a6fcdb
Merge branch 'k8s-extension/public' into user/amagraw/fix-bug/rename
pfrcks Dec 30, 2022
9b65294
Merge pull request #207 from pfrcks/user/amagraw/fix-bug/rename
deeksha345 Dec 30, 2022
887661d
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Jan 12, 2023
beffb3f
bump k8s-extension version to 1.3.8
Jan 12, 2023
f6e39ca
Merge branch 'k8s-extension/public' into release-1.3.8
deeksha345 Jan 12, 2023
6015026
Adding GA api version 2022-11-01 exposing isSystemExtension and suppo…
Nov 18, 2022
97c808f
Seperate args for plan name, product and publisher
Dec 13, 2022
d35686c
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Jan 13, 2023
c6d351f
Merge branch 'release-1.3.8' of https://github.com/AzureArcForKuberne…
Jan 13, 2023
0cd6017
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Jan 18, 2023
1b51c5e
updating cassete file
Jan 12, 2023
c1f8614
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Jan 19, 2023
2ff27e9
Merge pull request #199 from AzureArcForKubernetes/ariflakhani/2022-1…
Arif-lakhani Jan 20, 2023
e10938b
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Jan 23, 2023
2fb41e7
Merge branch 'k8s-extension/public' into release-1.3.8
deeksha345 Jan 23, 2023
8a48eea
updating HISTORY.rst
Jan 23, 2023
601d4c7
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
Jan 23, 2023
8319907
Merge pull request #209 from AzureArcForKubernetes/release-1.3.8
deeksha345 Jan 23, 2023
6fdced7
k8s-extension release 1.3.8
Jan 24, 2023
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
7 changes: 7 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
===============

1.3.8
++++++++++++++++++
* Fixes to address the bug with msi auth mode for azuremonitor-containers extension version >= 3.0.0
* microsoft.dapr: disable apply-CRDs hook if auto-upgrade is disabled
* microsoft.azuremonitor.containers: ContainerInsights Extension add dataCollectionSettings to configuration settings
* k8s-extension Adding GA api version 2022-11-01 exposing isSystemExtension and support

1.3.7
++++++++++++++++++
* microsoft.dapr: prompt user for existing dapr installation during extension create
Expand Down
4 changes: 4 additions & 0 deletions src/k8s-extension/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ az k8s-extension create \
--version versionNumber \
--auto-upgrade-minor-version autoUpgrade \
--configuration-settings exampleSetting=exampleValue \
--plan-name examplePlanName \
--plan-publisher examplePublisher \
--plan-product exampleOfferId \

```

##### Get a KubernetesExtension
Expand Down
9 changes: 9 additions & 0 deletions src/k8s-extension/azext_k8s_extension/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ def k8s_extension_show_table_format(result):


def __get_table_row(result):
plan_name, plan_publisher, plan_product = '', '', ''
if result['plan']:
plan_name = result['plan']['name']
plan_publisher = result['plan']['publisher']
plan_product = result['plan']['product']
return OrderedDict([
('name', result['name']),
('extensionType', result.get('extensionType', '')),
('version', result.get('version', '')),
('provisioningState', result.get('provisioningState', '')),
('lastModifiedAt', result.get('systemData', {}).get('lastModifiedAt', '')),
('plan_name', plan_name),
{'plan_publisher', plan_publisher},
('plan_product', plan_product),
('isSystemExtension', result.get('isSystemExtension', '')),
])


Expand Down
14 changes: 10 additions & 4 deletions src/k8s-extension/azext_k8s_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@

helps[f'{consts.EXTENSION_NAME} create'] = f"""
type: command
short-summary: Create a Kubernetes Extension.
short-summary: Create a Kubernetes Cluster Extension, including purchasing an extension Offer from Azure Marketplace (AKS only). Please refer to the example at the end to see how to create an extension or purchase an extension offer.
examples:
- name: Create a Kubernetes Extension
text: |-
az {consts.EXTENSION_NAME} create --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --name myextension \
--extension-type microsoft.openservicemesh --scope cluster --release-train stable
- name: Create a Kubernetes Marketplace Extension
text: |-
az {consts.EXTENSION_NAME} create --resource-group my-resource-group \
--cluster-name mycluster --cluster-type managedClusters --name myextension \
--extension-type Contoso.AzureVoteKubernetesAppTest --scope cluster --release-train stable \
--plan-name testplan --plan-product kubernetest_apps_demo_offer --plan-publisher test_test_mix3pptest0011614206850774
"""

helps[f'{consts.EXTENSION_NAME} list'] = f"""
Expand Down Expand Up @@ -67,9 +73,9 @@
--cluster-name mycluster --cluster-type connectedClusters \
--name myextension --auto-upgrade true/false --version extension-version \
--release-train stable --configuration-settings settings-key=settings-value \
--configuration-protected-settings protected-settings-key=protected-value \
--configuration-settings-file=config-settings-file \
--configuration-protected-settings-file=protected-settings-file
--config-protected-settings protected-settings-key=protected-value \
--config-settings-file=config-settings-file \
--config-protected-file=protected-settings-file
"""

helps[f'{consts.EXTENSION_NAME} extension-types'] = """
Expand Down
23 changes: 17 additions & 6 deletions src/k8s-extension/azext_k8s_extension/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .action import (
AddConfigurationSettings,
AddConfigurationProtectedSettings
AddConfigurationProtectedSettings,
)


Expand Down Expand Up @@ -52,30 +52,41 @@ def load_arguments(self, _):
help='Specify the release train for the extension type.')
c.argument('configuration_settings',
arg_group="Configuration",
options_list=['--configuration-settings', '--config-settings', '--config'],
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-settings', '--config-protected'],
options_list=['--config-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-settings-file', '--config-file'],
options_list=['--config-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-settings-file', '--config-protected-file'],
options_list=['--config-protected-file', '--protected-settings-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\'')

c.argument('plan_name',
arg_group="Marketplace",
options_list=['--plan-name'],
help='The plan name is referring to the Plan ID of the extension that is being taken from Marketplace portal under Usage Information + Support')
c.argument('plan_product',
arg_group="Marketplace",
options_list=['--plan-product'],
help='The plan product is referring to the Product ID of the extension that is being taken from Marketplace portal under Usage Information + Support. An example of this is the name of the ISV offering used.')
c.argument('plan_publisher',
arg_group="Marketplace",
options_list=['--plan-publisher'],
help='The plan publisher is referring to the Publisher ID of the extension that is being taken from Marketplace portal under Usage Information + Support')
with self.argument_context(f"{consts.EXTENSION_NAME} update") as c:
c.argument('yes',
options_list=['--yes', '-y'],
Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/azext_k8s_extension/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
PROVISIONED_CLUSTER_TYPE = "provisionedclusters"

CONNECTED_CLUSTER_API_VERSION = "2021-10-01"
MANAGED_CLUSTER_API_VERSION = "2021-10-01"
MANAGED_CLUSTER_API_VERSION = "2022-11-01"
APPLIANCE_API_VERSION = "2021-10-31-preview"
HYBRIDCONTAINERSERVICE_API_VERSION = "2022-05-01-preview"

Expand Down
6 changes: 6 additions & 0 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def create_k8s_extension(
configuration_settings_file=None,
configuration_protected_settings_file=None,
no_wait=False,
plan_name=None,
plan_publisher=None,
plan_product=None
):
"""Create a new Extension Instance."""

Expand Down Expand Up @@ -182,6 +185,9 @@ def create_k8s_extension(
config_protected_settings,
configuration_settings_file,
configuration_protected_settings_file,
plan_name,
plan_publisher,
plan_product
)

# Common validations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class AzureDefender(DefaultExtension):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file, plan_name,
plan_publisher, plan_product):

"""ExtensionType 'microsoft.azuredefender.kubernetes' specific validations & defaults for Create
Must create and return a valid 'Extension' object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def __init__(self):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file, plan_name,
plan_publisher, plan_product):

logger.warning("Troubleshooting: {}".format(self.TSG_LINK))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import datetime
import json
import re

from ..utils import get_cluster_rp_api_version
from .. import consts
Expand Down Expand Up @@ -36,7 +37,8 @@ class ContainerInsights(DefaultExtension):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file,
plan_name, plan_publisher, plan_product):
"""ExtensionType 'microsoft.azuremonitor.containers' specific validations & defaults for Create
Must create and return a valid 'Extension' object.

Expand Down Expand Up @@ -453,6 +455,7 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r
subscription_id = get_subscription_id(cmd.cli_ctx)
workspace_resource_id = ''
useAADAuth = False
extensionSettings = {}

if configuration_settings is not None:
if 'loganalyticsworkspaceresourceid' in configuration_settings:
Expand All @@ -473,6 +476,26 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r
logger.info("provided useAADAuth flag is : %s", useAADAuthSetting)
if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting):
useAADAuth = True
if useAADAuth and ('dataCollectionSettings' in configuration_settings):
dataCollectionSettingsString = configuration_settings["dataCollectionSettings"]
logger.info("provided dataCollectionSettings is : %s", dataCollectionSettingsString)
dataCollectionSettings = json.loads(dataCollectionSettingsString)
if 'interval' in dataCollectionSettings.keys():
intervalValue = dataCollectionSettings["interval"]
if (bool(re.match(r'^[0-9]+[m]$', intervalValue))) is False:
raise InvalidArgumentValueError('interval format must be in <number>m')
intervalValue = int(intervalValue.rstrip("m"))
if intervalValue <= 0 or intervalValue > 30:
raise InvalidArgumentValueError('interval value MUST be in the range from 1m to 30m')
if 'namespaceFilteringMode' in dataCollectionSettings.keys():
namespaceFilteringModeValue = dataCollectionSettings["namespaceFilteringMode"].lower()
if namespaceFilteringModeValue not in ["off", "exclude", "include"]:
raise InvalidArgumentValueError('namespaceFilteringMode value MUST be either Off or Exclude or Include')
if 'namespaces' in dataCollectionSettings.keys():
namspaces = dataCollectionSettings["namespaces"]
if isinstance(namspaces, list) is False:
raise InvalidArgumentValueError('namespaces must be an array type')
extensionSettings["dataCollectionSettings"] = dataCollectionSettings

workspace_resource_id = workspace_resource_id.strip()

Expand Down Expand Up @@ -502,7 +525,7 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r
if is_ci_extension_type:
if useAADAuth:
logger.info("creating data collection rule and association")
_ensure_container_insights_dcr_for_monitoring(cmd, subscription_id, cluster_resource_group_name, cluster_rp, cluster_type, cluster_name, workspace_resource_id)
_ensure_container_insights_dcr_for_monitoring(cmd, subscription_id, cluster_resource_group_name, cluster_rp, cluster_type, cluster_name, workspace_resource_id, extensionSettings)
elif not _is_container_insights_solution_exists(cmd, workspace_resource_id):
logger.info("Creating ContainerInsights solution resource, since it doesn't exist and it is using legacy authentication")
_ensure_container_insights_for_monitoring(cmd, workspace_resource_id).result()
Expand All @@ -520,6 +543,7 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r

# workspace key not used in case of AAD MSI auth
configuration_protected_settings['omsagent.secret.key'] = "<not_used>"
configuration_protected_settings['amalogs.secret.key'] = "<not_used>"
if not useAADAuth:
shared_keys = log_analytics_client.shared_keys.get_shared_keys(
workspace_rg_name, workspace_name)
Expand Down Expand Up @@ -570,7 +594,7 @@ def get_existing_container_insights_extension_dcr_tags(cmd, dcr_url):
return tags


def _ensure_container_insights_dcr_for_monitoring(cmd, subscription_id, cluster_resource_group_name, cluster_rp, cluster_type, cluster_name, workspace_resource_id):
def _ensure_container_insights_dcr_for_monitoring(cmd, subscription_id, cluster_resource_group_name, cluster_rp, cluster_type, cluster_name, workspace_resource_id, extensionSettings):
from azure.core.exceptions import HttpResponseError

cluster_region = ''
Expand Down Expand Up @@ -665,6 +689,7 @@ def _ensure_container_insights_dcr_for_monitoring(cmd, subscription_id, cluster_
"Microsoft-ContainerInsights-Group-Default"
],
"extensionName": "ContainerInsights",
"extensionSettings": extensionSettings
}
]
},
Expand Down
Loading