From ef4dab072a057e4f9800437f3b073cc2623157bb Mon Sep 17 00:00:00 2001 From: Candice Ye Date: Mon, 22 Nov 2021 13:28:51 -0800 Subject: [PATCH] Enabled deployment of Azure Arc data controllers in directly connected mode (#17707) * Added fields for connectivity mode, custom loc, auto-metrics, auto-logs, and the dynamic enablement of such fields. * Changed the description of the data controller details page. * Change notebook params to work for direct mode * Added login to dc deployment notebooks * Fixed auto upload metrics and logs true/false, separated login into another cell. * Removed localization of indirect and direct connectivity labels. --- .../deploy.arc.data.controller.ipynb | 216 ++++++++++-------- extensions/arc/package.json | 53 ++++- extensions/arc/package.nls.json | 11 +- 3 files changed, 185 insertions(+), 95 deletions(-) diff --git a/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb b/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb index 6a62c41cfe..84f30b687f 100644 --- a/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb +++ b/extensions/arc/notebooks/arcDeployment/deploy.arc.data.controller.ipynb @@ -1,27 +1,10 @@ { - "metadata": { - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python", - "version": "3.6.6", - "mimetype": "text/x-python", - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "pygments_lexer": "ipython3", - "nbconvert_exporter": "python", - "file_extension": ".py" - } - }, - "nbformat_minor": 2, - "nbformat": 4, "cells": [ { "cell_type": "markdown", + "metadata": { + "azdata_cell_guid": "82e60c1a-7acf-47ee-877f-9e85e92e11da" + }, "source": [ "![Microsoft](https://raw.githubusercontent.com/microsoft/azuredatastudio/main/extensions/arc/images/microsoft-small-logo.png)\n", " \n", @@ -33,13 +16,13 @@ "* The **Required information** will check and prompt you for password if it is not set in the environment variable. The password can be used to access the data controller.\n", "\n", "Please press the \"Run All\" button to run the notebook" - ], - "metadata": { - "azdata_cell_guid": "82e60c1a-7acf-47ee-877f-9e85e92e11da" - } + ] }, { "cell_type": "markdown", + "metadata": { + "azdata_cell_guid": "714582b9-10ee-409e-ab12-15a4825c9471" + }, "source": [ "### **Prerequisites** \n", "Ensure the following tools are installed and added to PATH before proceeding.\n", @@ -49,23 +32,25 @@ "|kubectl | Command-line tool for monitoring the underlying Kubernetes cluster | [Installation](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-using-native-package-management) |\n", "|Azure CLI (az) | Command-line tool for installing and managing resources in an Azure Arc cluster |[Installation](https://docs.microsoft.com/cli/azure/install-azure-cli-windows?tabs=azure-cli) |\n", "|Azure CLI arcdata extension | Commands for using Azure Arc for Azure data services. | [Installation](https://docs.microsoft.com/azure/azure-arc/data/install-arcdata-extension)" - ], - "metadata": { - "azdata_cell_guid": "714582b9-10ee-409e-ab12-15a4825c9471" - } + ] }, { "cell_type": "markdown", - "source": [ - "### **Setup**" - ], "metadata": { "azdata_cell_guid": "e3dd8e75-e15f-44b4-81fc-1f54d6f0b1e2" - } + }, + "source": [ + "### **Setup**" + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "azdata_cell_guid": "d973d5b4-7f0a-4a9d-b204-a16480f3940d", + "tags": [] + }, + "outputs": [], "source": [ "import sys,os,getpass\n", "def run_command(command):\n", @@ -74,56 +59,56 @@ " if _exit_code != 0:\n", " sys.exit(f'Command execution failed with exit code: {str(_exit_code)}.\\n\\t{command}\\n')\n", " print(f'Successfully executed: {command}')" - ], - "outputs": [], - "metadata": { - "azdata_cell_guid": "d973d5b4-7f0a-4a9d-b204-a16480f3940d", - "tags": [] - } + ] }, { "cell_type": "markdown", + "metadata": { + "azdata_cell_guid": "4b266b2d-bd1b-4565-92c9-3fc146cdce6d" + }, "source": [ "### **Set variables**\n", "Generated by Azure Data Studio using the values collected in the 'Create Azure Arc data controller' wizard." - ], - "metadata": { - "azdata_cell_guid": "4b266b2d-bd1b-4565-92c9-3fc146cdce6d" - } + ] }, { "cell_type": "markdown", - "source": [ - "### **Check dependencies**" - ], "metadata": { "azdata_cell_guid": "2544648b-59c9-4ce5-a3b6-87086e214d4c" - } + }, + "source": [ + "### **Check dependencies**" + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "run_command('az --version')" - ], - "outputs": [], "metadata": { "azdata_cell_guid": "691671d7-3f05-406c-a183-4cff7d17f83d", "tags": [] - } + }, + "outputs": [], + "source": [ + "run_command('az --version')" + ] }, { "cell_type": "markdown", - "source": [ - "### **Required information**" - ], "metadata": { "azdata_cell_guid": "0bb02e76-fee8-4dbc-a75b-d5b9d1b187d0" - } + }, + "source": [ + "### **Required information**" + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "azdata_cell_guid": "e7e10828-6cae-45af-8c2f-1484b6d4f9ac", + "tags": [] + }, + "outputs": [], "source": [ "if \"AZDATA_NB_VAR_ARC_ADMIN_PASSWORD\" in os.environ:\n", " arc_admin_password = os.environ[\"AZDATA_NB_VAR_ARC_ADMIN_PASSWORD\"]\n", @@ -135,85 +120,130 @@ " confirm_password = getpass.getpass(prompt = 'Confirm password')\n", " if arc_admin_password != confirm_password:\n", " sys.exit(f'Passwords do not match.')" - ], - "outputs": [], - "metadata": { - "azdata_cell_guid": "e7e10828-6cae-45af-8c2f-1484b6d4f9ac", - "tags": [] - } + ] }, { "cell_type": "markdown", - "source": [ - "### **Set and show current context**" - ], "metadata": { "azdata_cell_guid": "127c8042-181f-4862-a390-96e59c181d09" - } + }, + "source": [ + "### **Set and show current context**" + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "azdata_cell_guid": "7d1a03d4-1df8-48eb-bff0-0042603b95b1", + "tags": [] + }, + "outputs": [], "source": [ "os.environ[\"KUBECONFIG\"] = arc_config_file\n", "run_command(f'kubectl config use-context {arc_cluster_context}')\n", "run_command('kubectl config current-context')" - ], - "outputs": [], - "metadata": { - "azdata_cell_guid": "7d1a03d4-1df8-48eb-bff0-0042603b95b1", - "tags": [] - } + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ - "### **Create Azure Arc Data Controller**" - ], - "metadata": { - "azdata_cell_guid": "efe78cd3-ed73-4c9b-b586-fdd6c07dd37f" - } + "### **Log in to Azure CLI**" + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "is_indirect = arc_data_controller_connectivity_mode == 'Indirect'\n", + "\n", + "if not is_indirect:\n", + "\trun_command('az login')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "azdata_cell_guid": "efe78cd3-ed73-4c9b-b586-fdd6c07dd37f" + }, + "source": [ + "### **Create Azure Arc Data Controller**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "azdata_cell_guid": "373947a1-90b9-49ee-86f4-17a4c7d4ca76", + "tags": [] + }, + "outputs": [], "source": [ "print (f'Creating Azure Arc Data Controller: {arc_data_controller_name} using configuration {arc_cluster_context}')\n", "os.environ[\"AZDATA_USERNAME\"] = arc_admin_username\n", "os.environ[\"AZDATA_PASSWORD\"] = arc_admin_password\n", "\n", + "namespace = f' --k8s-namespace {arc_data_controller_namespace}' if is_indirect else ''\n", + "use_k8s = ' --use-k8s' if is_indirect else ''\n", + "\n", + "custom_location = f' --custom-location {arc_data_controller_custom_location}' if not is_indirect else ''\n", + "\n", + "auto_upload_metrics_value = 'true' if arc_data_controller_auto_upload_metrics == 'true' else 'false'\n", + "auto_upload_logs_value = 'true' if arc_data_controller_auto_upload_logs == 'true' else 'false'\n", + "\n", + "auto_upload_metrics = f' --auto-upload-metrics {auto_upload_metrics_value}' if not is_indirect else ''\n", + "auto_upload_logs = f' --auto-upload-logs {auto_upload_logs_value}' if not is_indirect else ''\n", + "\n", "if os.name == 'nt':\n", " print(f'If you don\\'t see output produced by az, you can run the following command in a terminal window to check the deployment status:\\n\\t {os.environ[\"AZDATA_NB_VAR_KUBECTL\"]} get pods -n {arc_data_controller_namespace}')\n", - "run_command(f'az arcdata dc create --connectivity-mode indirect --name {arc_data_controller_name} --k8s-namespace {arc_data_controller_namespace} --subscription {arc_subscription} --resource-group {arc_resource_group} --location {arc_data_controller_location} --storage-class {arc_data_controller_storage_class} --profile-name {arc_profile} --infrastructure {arc_infrastructure} --use-k8s')\n", + "run_command(f'az arcdata dc create --connectivity-mode {arc_data_controller_connectivity_mode} --name {arc_data_controller_name}{namespace} --subscription {arc_subscription} --resource-group {arc_resource_group} --location {arc_data_controller_location} --storage-class {arc_data_controller_storage_class} --profile-name {arc_profile} --infrastructure {arc_infrastructure}{custom_location}{auto_upload_metrics}{auto_upload_logs}{use_k8s}')\n", "print(f'Azure Arc Data Controller: {arc_data_controller_name} created.') " - ], - "outputs": [], - "metadata": { - "azdata_cell_guid": "373947a1-90b9-49ee-86f4-17a4c7d4ca76", - "tags": [] - } + ] }, { "cell_type": "markdown", - "source": [ - "### **Setting context to created Azure Arc Data Controller**" - ], "metadata": { "azdata_cell_guid": "a3ddc701-811d-4058-b3fb-b7295fcf50ae" - } + }, + "source": [ + "### **Setting context to created Azure Arc Data Controller**" + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "azdata_cell_guid": "c974561f-13d0-4e7a-b74b-d781c2e06d68" + }, + "outputs": [], "source": [ "# Setting context to Data Controller.\n", "#\n", "run_command(f'kubectl config set-context --current --namespace {arc_data_controller_namespace}')" - ], - "outputs": [], - "metadata": { - "azdata_cell_guid": "c974561f-13d0-4e7a-b74b-d781c2e06d68" - } + ] } - ] + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 } diff --git a/extensions/arc/package.json b/extensions/arc/package.json index 551e79349d..eb5148d27e 100644 --- a/extensions/arc/package.json +++ b/extensions/arc/package.json @@ -261,6 +261,20 @@ "label": "%arc.data.controller.details.description%", "labelWidth": "600px" }, + { + "type": "options", + "label": "%arc.data.controller.connectivity.mode%", + "required": true, + "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", + "options": { + "values": [ + "Indirect", + "Direct" + ], + "defaultValue": "Indirect", + "optionsType": "radio" + } + }, { "type": "text", "label": "%arc.data.controller.namespace%", @@ -273,7 +287,11 @@ ], "defaultValue": "arc", "required": true, - "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_NAMESPACE" + "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_NAMESPACE", + "enabled": { + "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", + "value": "Indirect" + } }, { "type": "text", @@ -310,6 +328,39 @@ "onpremises", "other" ] + }, + { + "type": "text", + "label": "%arc.data.controller.custom.location%", + "description": "%arc.data.controller.custom.location.description%", + "required": true, + "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CUSTOM_LOCATION", + "enabled": { + "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", + "value": "Direct" + } + }, + { + "type": "checkbox", + "label": "%arc.data.controller.auto.upload.metrics%", + "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_AUTO_UPLOAD_METRICS", + "description": "%arc.data.controller.auto.upload.metrics.description%", + "defaultValue": false, + "enabled": { + "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", + "value": "Direct" + } + }, + { + "type": "checkbox", + "label": "%arc.data.controller.auto.upload.logs%", + "variableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_AUTO_UPLOAD_LOGS", + "description": "%arc.data.controller.auto.upload.logs.description%", + "defaultValue": false, + "enabled": { + "target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE", + "value": "Direct" + } } ] }, diff --git a/extensions/arc/package.nls.json b/extensions/arc/package.nls.json index 7c6b41f9c3..bb8e663794 100644 --- a/extensions/arc/package.nls.json +++ b/extensions/arc/package.nls.json @@ -28,13 +28,22 @@ "arc.data.controller.project.details.title": "Azure details", "arc.data.controller.project.details.description": "Select the subscription to manage deployed resources and costs. Use resource groups like folders to organize and manage all your resources.", "arc.data.controller.details.title": "Data controller details", - "arc.data.controller.details.description": "Provide a namespace, name and storage class for your Azure Arc data controller. This name will be used to identify your Arc instance for remote management and monitoring.", + "arc.data.controller.details.description": "For indirect mode, provide a namespace, name and storage class for your Azure Arc data controller. This name will be used to identify your Arc instance for remote management and monitoring. For direct mode you do not need to provide a namespace, but please provide the custom location name.", + "arc.data.controller.connectivity.mode": "Connectivity mode", "arc.data.controller.namespace": "Data controller namespace", + "arc.data.controller.namespace.description": "Indirect mode only.", "arc.data.controller.namespace.validation.description": "Namespace must consist of lower case alphanumeric characters or '-', start/end with an alphanumeric character, and be 63 characters or fewer in length.", "arc.data.controller.name": "Data controller name", "arc.data.controller.name.validation.description": "Name must consist of lower case alphanumeric characters, '-' or '.', start/end with an alphanumeric character and be 253 characters or less in length.", "arc.data.controller.location": "Location", "arc.data.controller.infrastructure": "Infrastructure", + "arc.data.controller.custom.location": "Custom Location", + "arc.data.controller.custom.location.description": "The name of the custom location. Direct mode only.", + "arc.data.controller.auto.upload.metrics": "Auto-upload Metrics", + "arc.data.controller.auto.upload.metrics.description": "Enable the automatic upload of metrics. Direct mode only.", + "arc.data.controller.auto.upload.logs": "Auto-upload Logs", + "arc.data.controller.auto.upload.logs.description": "Enable the automatic upload of logs. Direct mode only.", + "arc.data.controller.admin.account.title": "Administrator account", "arc.data.controller.admin.account.name": "Data controller login", "arc.data.controller.admin.account.password": "Password",