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

bump k8s-extension version to 1.3.3 #170

Merged
merged 7 commits into from
Aug 18, 2022
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
3 changes: 3 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,9 @@ iot central user update:
central_dns_suffix:
rule_exclusions:
- no_parameter_defaults_for_update_commands
iot device-update update:
rule_exclusions:
- require_wait_command_if_no_wait
iot dps enrollment update:
parameters:
auth_type_dataplane:
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++
* [BREAKING CHANGE] Since the service no longer supports updating source resource id for role binding, so remove --source-resource-id of `aks trustedaccess rolebinding update` command
* change rolebinding create command parameter roles to comma-seperated
* Upgrade kollect command to use Periscope version 0.0.10 supporting enhanced Windows log collection.

0.5.93
++++++
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@

CONST_PERISCOPE_REPO_ORG = "azure"
CONST_PERISCOPE_CONTAINER_REGISTRY = "mcr.microsoft.com"
CONST_PERISCOPE_RELEASE_TAG = "v0.9"
CONST_PERISCOPE_IMAGE_VERSION = "0.0.9"
CONST_PERISCOPE_RELEASE_TAG = "0.0.10"
CONST_PERISCOPE_IMAGE_VERSION = "0.0.10"
CONST_PERISCOPE_NAMESPACE = "aks-periscope"

CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PUBLIC = "Public"
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@

examples:
- name: Create a new trusted access role binding
text: az aks trustedaccess rolebinding create -g myResourceGroup --cluster-name myCluster -n bindingName -s /subscriptions/0000/resourceGroups/myResourceGroup/providers/Microsoft.Demo/samples --roles Microsoft.Demo/samples/reader Microsoft.Demo/samples/writer
text: az aks trustedaccess rolebinding create -g myResourceGroup --cluster-name myCluster -n bindingName -s /subscriptions/0000/resourceGroups/myResourceGroup/providers/Microsoft.Demo/samples --roles Microsoft.Demo/samples/reader,Microsoft.Demo/samples/writer
"""

helps['aks trustedaccess rolebinding update'] = """
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,11 @@ def load_arguments(self, _):
'--name', '-n'], required=True, help='The role binding name.')

with self.argument_context('aks trustedaccess rolebinding create') as c:
c.argument('roles', nargs='*', help='space-separated roles: Microsoft.Demo/samples/reader Microsoft.Demo/samples/writer ...')
c.argument('roles', help='comma-separated roles: Microsoft.Demo/samples/reader,Microsoft.Demo/samples/writer,...')
c.argument('source_resource_id', options_list=['--source-resource-id', '-s'], help='The source resource id of the binding')

with self.argument_context('aks trustedaccess rolebinding update') as c:
c.argument('roles', nargs='*', help='space-separated roles: Microsoft.Demo/samples/reader Microsoft.Demo/samples/writer ...')
c.argument('roles', help='comma-separated roles: Microsoft.Demo/samples/reader,Microsoft.Demo/samples/writer,...')


def _get_default_install_location(exe_name):
Expand Down
46 changes: 44 additions & 2 deletions src/aks-preview/azext_aks_preview/aks_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import time

from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id
from enum import Flag, auto
from knack.log import get_logger
from knack.prompting import prompt_y_n
from knack.util import CLIError
from msrestazure.azure_exceptions import CloudError
from packaging import version
from tabulate import tabulate

from azext_aks_preview._client_factory import get_storage_client
from azext_aks_preview._client_factory import cf_agent_pools, get_storage_client

from azext_aks_preview._consts import (
CONST_CONTAINER_NAME_MAX_LENGTH,
Expand All @@ -34,6 +36,11 @@
logger = get_logger(__name__)


class ClusterFeatures(Flag):
NONE = 0
WIN_HPC = auto()


# pylint: disable=line-too-long
def aks_kollect_cmd(cmd, # pylint: disable=too-many-statements,too-many-locals
client,
Expand Down Expand Up @@ -137,7 +144,10 @@ def aks_kollect_cmd(cmd, # pylint: disable=too-many-statements,too-many-local
container_name = _generate_container_name(mc.fqdn, mc.private_fqdn)
sas_token = sas_token.strip('?')

kustomize_yaml = _get_kustomize_yaml(storage_account_name, sas_token, container_name, container_logs, kube_objects, node_logs, node_logs_windows)
cluster_features = _get_cluster_features(cmd.cli_ctx, resource_group_name, name)

run_id = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%SZ")
kustomize_yaml = _get_kustomize_yaml(storage_account_name, sas_token, container_name, run_id, cluster_features, container_logs, kube_objects, node_logs, node_logs_windows)
kustomize_folder = tempfile.mkdtemp()
kustomize_file_path = os.path.join(kustomize_folder, "kustomization.yaml")
try:
Expand Down Expand Up @@ -227,11 +237,20 @@ def aks_kanalyze_cmd(client, resource_group_name: str, name: str) -> None:
def _get_kustomize_yaml(storage_account_name,
sas_token,
container_name,
run_id,
cluster_features,
container_logs=None,
kube_objects=None,
node_logs_linux=None,
node_logs_windows=None):
components = {
'win-hpc': bool(cluster_features & ClusterFeatures.WIN_HPC)
}

component_content = "\n".join(f'- https://github.com/{CONST_PERISCOPE_REPO_ORG}/aks-periscope//deployment/components/{c}?ref={CONST_PERISCOPE_RELEASE_TAG}' for c, enabled in components.items() if enabled)

diag_config_vars = {
'DIAGNOSTIC_RUN_ID': run_id,
'DIAGNOSTIC_CONTAINERLOGS_LIST': container_logs,
'DIAGNOSTIC_KUBEOBJECTS_LIST': kube_objects,
'DIAGNOSTIC_NODELOGS_LIST_LINUX': node_logs_linux,
Expand All @@ -247,6 +266,9 @@ def _get_kustomize_yaml(storage_account_name,
resources:
- https://github.com/{CONST_PERISCOPE_REPO_ORG}/aks-periscope//deployment/base?ref={CONST_PERISCOPE_RELEASE_TAG}

components:
{component_content}

namespace: {CONST_PERISCOPE_NAMESPACE}

images:
Expand Down Expand Up @@ -313,6 +335,26 @@ def _generate_container_name(fqdn: str, private_fqdn: str) -> str:
return container_name


def _get_cluster_features(cli_ctx, resource_group_name, cluster_name):
agent_pool_client = cf_agent_pools(cli_ctx)
agent_pool_items = agent_pool_client.list(resource_group_name, cluster_name)
agent_pools = list(agent_pool_items)

features = ClusterFeatures.NONE
if _is_windows_hpc_supported(agent_pools):
features |= ClusterFeatures.WIN_HPC

return features


def _is_windows_hpc_supported(agent_pools):
# https://docs.microsoft.com/en-us/rest/api/aks/agent-pools/list?tabs=HTTP#agentpool
# The full (major.minor.patch) version *may* be stored in currentOrchestratorVersion.
# If not, it'll be in orchestratorVersion.
windows_k8s_versions = [p.current_orchestrator_version or p.orchestrator_version for p in agent_pools if p.os_type.casefold() == "Windows".casefold()]
return all([version.parse(v) >= version.parse("1.23.0") for v in windows_k8s_versions])


def _display_diagnostics_report(temp_kubeconfig_path): # pylint: disable=too-many-statements
if not which('kubectl'):
raise CLIError('Can not find kubectl executable in PATH')
Expand Down
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,8 @@ def aks_trustedaccess_role_binding_create(cmd, client, resource_group_name, clus
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="trusted_access_role_bindings",
)
roleBinding = TrustedAccessRoleBinding(source_resource_id=source_resource_id, roles=roles)
roleList = roles.split(',')
roleBinding = TrustedAccessRoleBinding(source_resource_id=source_resource_id, roles=roleList)
return client.create_or_update(resource_group_name, cluster_name, role_binding_name, roleBinding)


Expand Down
115 changes: 115 additions & 0 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11713,6 +11713,79 @@
"version": "0.16.1"
},
"sha256Digest": "d6c814af4bdc4020bbb2971f718796fac0e12a4319258e6704d711c2f9adca38"
},
{
"downloadUrl": "https://github.com/Azure/azure-iot-cli-extension/releases/download/v0.17.0/azure_iot-0.17.0-py3-none-any.whl",
"filename": "azure_iot-0.17.0-py3-none-any.whl",
"metadata": {
"azext.minCliCoreVersion": "2.30.0",
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: MIT License"
],
"extensions": {
"python.details": {
"contacts": [
{
"email": "[email protected]",
"name": "Microsoft",
"role": "author"
}
],
"document_names": {
"description": "DESCRIPTION.rst"
},
"project_urls": {
"Home": "https://github.com/azure/azure-iot-cli-extension"
}
}
},
"extras": [
"uamqp"
],
"generator": "bdist_wheel (0.30.0)",
"license": "MIT",
"metadata_version": "2.0",
"name": "azure-iot",
"requires_python": ">=3.7",
"run_requires": [
{
"requires": [
"azure-core (<2.0.0,<2.0.0azure-mgmt-core>=1.3.0,>=1.24.0)",
"azure-iot-device (~=2.11)",
"jsonschema (~=3.2.0)",
"msrest (>=0.6.21)",
"msrestazure (<2.0.0,>=0.6.3)",
"packaging",
"tqdm (~=4.62)"
]
},
{
"extra": "uamqp",
"requires": [
"uamqp (~=1.2)"
]
},
{
"environment": "python_version < \"3.8\"",
"requires": [
"importlib-metadata"
]
}
],
"summary": "The Azure IoT extension for Azure CLI.",
"version": "0.17.0"
},
"sha256Digest": "924d4cf255efe8a8950d968ed474be42b9da790c46381893a1d2892fdf72281e"
}
],
"azurestackhci": [
Expand Down Expand Up @@ -25285,6 +25358,48 @@
"version": "1.3.1"
},
"sha256Digest": "c6231d4bf4f05b5e9f169ddc8dd278113b4c8dcedb3506684641f09d1dfb36ce"
},
{
"downloadUrl": "https://azcliprod.blob.core.windows.net/cli-extensions/k8s_extension-1.3.2-py3-none-any.whl",
"filename": "k8s_extension-1.3.2-py3-none-any.whl",
"metadata": {
"azext.minCliCoreVersion": "2.24.0",
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License"
],
"extensions": {
"python.details": {
"contacts": [
{
"email": "[email protected]",
"name": "Microsoft Corporation",
"role": "author"
}
],
"document_names": {
"description": "DESCRIPTION.rst"
},
"project_urls": {
"Home": "https://github.com/Azure/azure-cli-extensions/tree/main/src/k8s-extension"
}
}
},
"generator": "bdist_wheel (0.30.0)",
"license": "MIT",
"metadata_version": "2.0",
"name": "k8s-extension",
"summary": "Microsoft Azure Command-Line Tools K8s-extension Extension",
"version": "1.3.2"
},
"sha256Digest": "f081a5501ade1d6aa9eb62b3fb58de78adb614031c6bbd48b1d8c2af0af1197a"
}
],
"k8sconfiguration": [
Expand Down
4 changes: 4 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.3.3
++++++++++++++++++
* microsoft.azuremonitor.containers: add condition to use different api version for provisioned clusters

1.3.2
++++++++++++++++++
* Create identity for Appliances clusters
Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "1.3.2"
VERSION = "1.3.3"

with open("README.rst", "r", encoding="utf-8") as f:
README = f.read()
Expand Down