From 76b546f6818f436b56668fbc2fe1078cd26c3411 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Thu, 7 Nov 2019 10:40:10 -0500 Subject: [PATCH 1/3] [openshift]Add --loganalytics_workspace_resource_id and monitoring profile --- .../azure/cli/command_modules/acs/_help.py | 5 +++ .../azure/cli/command_modules/acs/_params.py | 1 + .../azure/cli/command_modules/acs/custom.py | 39 +++++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/_help.py b/src/azure-cli/azure/cli/command_modules/acs/_help.py index 1afb0b5c4d8..d234e4ddd34 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -896,6 +896,9 @@ - name: --customer-admin-group-id type: string short-summary: The Object ID of an Azure Active Directory Group that memberships will get synced into the OpenShift group "osa-customer-admins". If not specified, no cluster admin access will be granted. + - name: --loganalytics-workspace-resource-id + type: string + short-summary: The resource ID of an existing Log Analytics Workspace to use for storing monitoring data. examples: @@ -907,6 +910,8 @@ text: az openshift create -g MyResourceGroup -n MyManagedCluster --aad-client-app-id {APP_ID} --aad-client-app-secret {APP_SECRET} --aad-tenant-id {TENANT_ID} --compute-count 5 - name: Create an Openshift cluster using a custom vnet text: az openshift create -g MyResourceGroup -n MyManagedCluster --vnet-peer "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/openshift-vnet/providers/Microsoft.Network/virtualNetworks/test" + - name: Create an Openshift cluster with Log Analytics monitoring enabled + text: az openshift create -g MyResourceGroup -n MyManagedCluster --loganalytics-workspace-resource-id {LOGANALYTICS_WORKSPACE_RESOURCE_ID} """ helps['openshift delete'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/acs/_params.py b/src/azure-cli/azure/cli/command_modules/acs/_params.py index f18652f5395..b655cd8c812 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_params.py @@ -321,6 +321,7 @@ def load_arguments(self, _): c.argument('name', validator=validate_linux_host_name) c.argument('compute_vm_size', options_list=['--compute-vm-size', '-s']) c.argument('customer_admin_group_id', options_list=['--customer-admin-group-id']) + c.argument('loganalytics_workspace_resource_id') def _get_default_install_location(exe_name): diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index 05ba7d76d14..13f191eae39 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -81,6 +81,8 @@ from azure.mgmt.containerservice.v2019_04_30.models import OpenShiftRouterProfile from azure.mgmt.containerservice.v2019_04_30.models import OpenShiftManagedClusterAuthProfile from azure.mgmt.containerservice.v2019_04_30.models import NetworkProfile +from azure.mgmt.containerservice.v2019_09_30_preview.models import OpenShiftManagedCluster as OpenShiftManagedClusterMonitor # pylint: disable=line-too-long +from azure.mgmt.containerservice.v2019_09_30_preview.models import OpenShiftManagedClusterMonitorProfile from ._client_factory import cf_container_services from ._client_factory import cf_resource_groups @@ -3124,6 +3126,7 @@ def openshift_create(cmd, client, resource_group_name, name, # pylint: disable= vnet_peer=None, tags=None, no_wait=False, + loganalytics_workspace_resource_id=None, customer_admin_group_id=None): if location is None: @@ -3194,17 +3197,37 @@ def openshift_create(cmd, client, resource_group_name, name, # pylint: disable= namespace='Microsoft.Network', type='virtualNetwork', name=vnet_peer ) + if loganalytics_workspace_resource_id is not None: + loganalytics_workspace_resource_id = loganalytics_workspace_resource_id.strip() + if not loganalytics_workspace_resource_id.startswith('/'): + loganalytics_workspace_resource_id = '/' + loganalytics_workspace_resource_id + if loganalytics_workspace_resource_id.endswith('/'): + loganalytics_workspace_resource_id = loganalytics_workspace_resource_id.rstrip('/') + monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, loganalytics_workspace_resource_id=loganalytics_workspace_resource_id) # pylint: disable=line-too-long + else: + monitor_profile = None network_profile = NetworkProfile(vnet_cidr=vnet_prefix, peer_vnet_id=vnet_peer) - osamc = OpenShiftManagedCluster( - location=location, tags=tags, - open_shift_version="v3.11", - network_profile=network_profile, - auth_profile=auth_profile, - agent_pool_profiles=agent_pool_profiles, - master_pool_profile=agent_master_pool_profile, - router_profiles=[default_router_profile]) + if monitor_profile is not None: + osamc = OpenShiftManagedClusterMonitor( + location=location, tags=tags, + open_shift_version="v3.11", + network_profile=network_profile, + auth_profile=auth_profile, + agent_pool_profiles=agent_pool_profiles, + master_pool_profile=agent_master_pool_profile, + router_profiles=[default_router_profile], + monitor_profile=monitor_profile) + else: + osamc = OpenShiftManagedCluster( + location=location, tags=tags, + open_shift_version="v3.11", + network_profile=network_profile, + auth_profile=auth_profile, + agent_pool_profiles=agent_pool_profiles, + master_pool_profile=agent_master_pool_profile, + router_profiles=[default_router_profile]) try: # long_running_operation_timeout=300 From c82bfe3ad4be4b05087c54062043dbf22f6abf69 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Mon, 11 Nov 2019 12:40:26 -0500 Subject: [PATCH 2/3] [openshift]Change flag to "--workspace-resource-id" --- .../azure/cli/command_modules/acs/_help.py | 4 ++-- .../azure/cli/command_modules/acs/_params.py | 2 +- .../azure/cli/command_modules/acs/custom.py | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/_help.py b/src/azure-cli/azure/cli/command_modules/acs/_help.py index d234e4ddd34..66817404833 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -896,7 +896,7 @@ - name: --customer-admin-group-id type: string short-summary: The Object ID of an Azure Active Directory Group that memberships will get synced into the OpenShift group "osa-customer-admins". If not specified, no cluster admin access will be granted. - - name: --loganalytics-workspace-resource-id + - name: --workspace-resource-id type: string short-summary: The resource ID of an existing Log Analytics Workspace to use for storing monitoring data. @@ -911,7 +911,7 @@ - name: Create an Openshift cluster using a custom vnet text: az openshift create -g MyResourceGroup -n MyManagedCluster --vnet-peer "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/openshift-vnet/providers/Microsoft.Network/virtualNetworks/test" - name: Create an Openshift cluster with Log Analytics monitoring enabled - text: az openshift create -g MyResourceGroup -n MyManagedCluster --loganalytics-workspace-resource-id {LOGANALYTICS_WORKSPACE_RESOURCE_ID} + text: az openshift create -g MyResourceGroup -n MyManagedCluster --workspace-resource-id {WORKSPACE_RESOURCE_ID} """ helps['openshift delete'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/acs/_params.py b/src/azure-cli/azure/cli/command_modules/acs/_params.py index b655cd8c812..631a2db79f9 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_params.py @@ -321,7 +321,7 @@ def load_arguments(self, _): c.argument('name', validator=validate_linux_host_name) c.argument('compute_vm_size', options_list=['--compute-vm-size', '-s']) c.argument('customer_admin_group_id', options_list=['--customer-admin-group-id']) - c.argument('loganalytics_workspace_resource_id') + c.argument('workspace_resource_id') def _get_default_install_location(exe_name): diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index 13f191eae39..d6a73b85c42 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -3126,7 +3126,7 @@ def openshift_create(cmd, client, resource_group_name, name, # pylint: disable= vnet_peer=None, tags=None, no_wait=False, - loganalytics_workspace_resource_id=None, + workspace_resource_id=None, customer_admin_group_id=None): if location is None: @@ -3197,13 +3197,13 @@ def openshift_create(cmd, client, resource_group_name, name, # pylint: disable= namespace='Microsoft.Network', type='virtualNetwork', name=vnet_peer ) - if loganalytics_workspace_resource_id is not None: - loganalytics_workspace_resource_id = loganalytics_workspace_resource_id.strip() - if not loganalytics_workspace_resource_id.startswith('/'): - loganalytics_workspace_resource_id = '/' + loganalytics_workspace_resource_id - if loganalytics_workspace_resource_id.endswith('/'): - loganalytics_workspace_resource_id = loganalytics_workspace_resource_id.rstrip('/') - monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, loganalytics_workspace_resource_id=loganalytics_workspace_resource_id) # pylint: disable=line-too-long + if workspace_resource_id is not None: + workspace_resource_id = workspace_resource_id.strip() + if not workspace_resource_id.startswith('/'): + workspace_resource_id = '/' + workspace_resource_id + if workspace_resource_id.endswith('/'): + workspace_resource_id = workspace_resource_id.rstrip('/') + monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, workspace_resource_id=workspace_resource_id) # pylint: disable=line-too-long else: monitor_profile = None From 19f6a97e31fd67518e33fc242db7492877bc4847 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Tue, 12 Nov 2019 10:53:05 -0500 Subject: [PATCH 3/3] [openshift]Add monitoring profile for "az openshift create" Add flag "--workspace-resource-id" to "az openshift create" --- src/azure-cli/HISTORY.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index ed119ac852b..09eaf29943c 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -2,6 +2,10 @@ Release History =============== +**Azure Red Hat OpenShift** + +* Add `--workspace-resource-id` flag to allow creation of Azure Red Hat Openshift cluster with monitoring +* Add `monitor_profile` to create Azure Red Hat OpenShift cluster with monitoring **AKS**