Add arc deployment contributions to arc extension (#11032)

* Add arc deployment contributions to arc extension

* Add logo image

* update images

* Update strings
This commit is contained in:
Charles Gagnon
2020-06-22 12:54:56 -07:00
committed by GitHub
parent 637bc8d5ba
commit 681e5f5077
14 changed files with 1607 additions and 4 deletions

View File

@@ -0,0 +1,250 @@
{
"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",
"source": [
"![Microsoft](https://raw.githubusercontent.com/microsoft/azuredatastudio/main/extensions/arc/images/microsoft-small-logo.png)\n",
" \n",
"## Deploy Azure Arc Data Controller on an existing cluster\n",
" \n",
"This notebook walks through the process of deploying a <a href=\"https://azure.microsoft.com/services/azure-arc/\">Azure Arc controller</a> on an existing cluster.\n",
" \n",
"* Follow the instructions in the **Prerequisites** cell to install the tools if not already installed.\n",
"* 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",
"<span style=\"color:red\"><font size=\"3\">Please press the \"Run Cells\" button to run the notebook</font></span>"
],
"metadata": {
"azdata_cell_guid": "82e60c1a-7acf-47ee-877f-9e85e92e11da"
}
},
{
"cell_type": "markdown",
"source": [
"### **Prerequisites** \n",
"Ensure the following tools are installed and added to PATH before proceeding.\n",
" \n",
"|Tools|Description|Installation|\n",
"|---|---|---|\n",
"|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",
"|azdata | Command-line tool for installing and managing resources in an Azure Arc cluster |[Installation](https://github.com/microsoft/Azure-data-services-on-Azure-Arc/blob/master/scenarios/001-install-client-tools.md) |"
],
"metadata": {
"azdata_cell_guid": "714582b9-10ee-409e-ab12-15a4825c9471"
}
},
{
"cell_type": "markdown",
"source": [
"### **Setup**"
],
"metadata": {
"azdata_cell_guid": "e3dd8e75-e15f-44b4-81fc-1f54d6f0b1e2"
}
},
{
"cell_type": "code",
"source": [
"import pandas,sys,os,json,html,getpass,time, tempfile\n",
"pandas_version = pandas.__version__.split('.')\n",
"pandas_major = int(pandas_version[0])\n",
"pandas_minor = int(pandas_version[1])\n",
"pandas_patch = int(pandas_version[2])\n",
"if not (pandas_major > 0 or (pandas_major == 0 and pandas_minor > 24) or (pandas_major == 0 and pandas_minor == 24 and pandas_patch >= 2)):\n",
" sys.exit('Please upgrade the Notebook dependency before you can proceed, you can do it by running the \"Reinstall Notebook dependencies\" command in command palette (View menu -> Command Palette…).')\n",
"def run_command(command):\n",
" print(\"Executing: \" + command)\n",
" !{command}\n",
" 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}')"
],
"metadata": {
"azdata_cell_guid": "d973d5b4-7f0a-4a9d-b204-a16480f3940d",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Set variables**\n",
"Generated by Azure Data Studio using the values collected in the Azure Arc Data controller create 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"
}
},
{
"cell_type": "code",
"source": [
"run_command('azdata --version')"
],
"metadata": {
"azdata_cell_guid": "691671d7-3f05-406c-a183-4cff7d17f83d",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Required information**"
],
"metadata": {
"azdata_cell_guid": "0bb02e76-fee8-4dbc-a75b-d5b9d1b187d0"
}
},
{
"cell_type": "code",
"source": [
"if \"AZDATA_NB_VAR_ARC_DOCKER_PASSWORD\" in os.environ:\n",
" arc_docker_password = os.environ[\"AZDATA_NB_VAR_ARC_DOCKER_PASSWORD\"]\n",
"if \"AZDATA_NB_VAR_ARC_ADMIN_PASSWORD\" in os.environ:\n",
" arc_admin_password = os.environ[\"AZDATA_NB_VAR_ARC_ADMIN_PASSWORD\"]\n",
"else:\n",
" if arc_admin_password == \"\":\n",
" arc_admin_password = getpass.getpass(prompt = 'Azure Arc Data controller password')\n",
" if arc_admin_password == \"\":\n",
" sys.exit(f'Password is required.')\n",
" confirm_password = getpass.getpass(prompt = 'Confirm password')\n",
" if arc_admin_password != confirm_password:\n",
" sys.exit(f'Passwords do not match.')"
],
"metadata": {
"azdata_cell_guid": "e7e10828-6cae-45af-8c2f-1484b6d4f9ac",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Set and show current context**"
],
"metadata": {
"azdata_cell_guid": "127c8042-181f-4862-a390-96e59c181d09"
}
},
{
"cell_type": "code",
"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')"
],
"metadata": {
"azdata_cell_guid": "7d1a03d4-1df8-48eb-bff0-0042603b95b1",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Create Azure Arc Data controller**"
],
"metadata": {
"azdata_cell_guid": "efe78cd3-ed73-4c9b-b586-fdd6c07dd37f"
}
},
{
"cell_type": "code",
"source": [
"print (f'Creating Azure Arc controller: {arc_data_controller_name} using configuration {arc_cluster_context}')\n",
"os.environ[\"ACCEPT_EULA\"] = 'yes'\n",
"os.environ[\"AZDATA_USERNAME\"] = arc_admin_username\n",
"os.environ[\"AZDATA_PASSWORD\"] = arc_admin_password\n",
"os.environ[\"DOCKER_USERNAME\"] = arc_docker_username\n",
"os.environ[\"DOCKER_PASSWORD\"] = arc_docker_password\n",
"if os.name == 'nt':\n",
" print(f'If you don\\'t see output produced by azdata, 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 -A')\n",
"run_command(f'azdata arc dc create --connectivity-mode {arc_data_controller_connectivity_mode} -n {arc_data_controller_name} -ns {arc_data_controller_namespace} -s {arc_subscription} -g {arc_resource_group} -l {arc_data_controller_location} -p {arc_profile}')\n",
"print(f'Azure Arc Data controller cluster: {arc_data_controller_name} created.') "
],
"metadata": {
"azdata_cell_guid": "373947a1-90b9-49ee-86f4-17a4c7d4ca76",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Setting context to created Azure Arc Data controller**"
],
"metadata": {
"azdata_cell_guid": "a3ddc701-811d-4058-b3fb-b7295fcf50ae"
}
},
{
"cell_type": "code",
"source": [
"# Setting context to data controller.\n",
"#\n",
"run_command(f'kubectl config set-context --current --namespace {arc_data_controller_namespace}')"
],
"metadata": {
"azdata_cell_guid": "c974561f-13d0-4e7a-b74b-d781c2e06d68"
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Login to the data controller.**\n"
],
"metadata": {
"azdata_cell_guid": "9376b2ab-0edf-478f-9e3c-5ff46ae3501a"
}
},
{
"cell_type": "code",
"source": [
"# Login to the data controller.\n",
"#\n",
"run_command(f'azdata login -n {arc_data_controller_namespace}')"
],
"metadata": {
"azdata_cell_guid": "9aed0c5a-2c8a-4ad7-becb-60281923a196"
},
"outputs": [],
"execution_count": null
}
]
}

View File

@@ -0,0 +1,155 @@
{
"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",
"source": [
"![Microsoft](https://raw.githubusercontent.com/microsoft/azuredatastudio/main/extensions/arc/images/microsoft-small-logo.png)\n",
" \n",
"## Deploy a PostgreSQL server group on an existing Azure Arc data cluster\n",
" \n",
"This notebook walks through the process of deploying a PostgreSQL server group on an existing Azure Arc data cluster.\n",
" \n",
"* Follow the instructions in the **Prerequisites** cell to install the tools if not already installed.\n",
"* Make sure you have the target Azure Arc data cluster already created.\n",
"\n",
"<span style=\"color:red\"><font size=\"3\">Please press the \"Run Cells\" button to run the notebook</font></span>"
],
"metadata": {
"azdata_cell_guid": "e4ed0892-7b5a-4d95-bd0d-a6c3eb0b2c99"
}
},
{
"cell_type": "markdown",
"source": [
"### **Check prerequisites**"
],
"metadata": {
"azdata_cell_guid": "68531b91-ddce-47d7-a1d8-2ddc3d17f3e7"
}
},
{
"cell_type": "code",
"source": [
"import sys,os,json,subprocess\n",
"def run_command():\n",
" print(\"Executing: \" + cmd)\n",
" output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True )\n",
" if output.returncode != 0:\n",
" print(f'Command: {cmd} failed \\n')\n",
" print(f'\\t>>>Error output: {output.stderr.decode(\"utf-8\")}\\n')\n",
" sys.exit(f'exit code: {output.returncode}\\n')\n",
" print(f'Successfully executed: {cmd}')\n",
" print(f'\\t>>>Output: {output.stdout.decode(\"utf-8\")}\\n')\n",
" return output.stdout.decode(\"utf-8\")\n",
"cmd = 'azdata --version'\n",
"out = run_command()\n",
""
],
"metadata": {
"azdata_cell_guid": "749d8dba-3da8-46e9-ae48-2b38056ab7a2",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"#### **Ensure PostgreSQL server group name, subscription id and resource group name**"
],
"metadata": {
"azdata_cell_guid": "68ec0760-27d1-4ded-9a9f-89077c40b8bb"
}
},
{
"cell_type": "code",
"source": [
"# Required Values\n",
"subscription = os.environ[\"AZDATA_NB_VAR_ARC_SUBSCRIPTION\"]\n",
"resource_group_name = os.environ[\"AZDATA_NB_VAR_ARC_RESOURCE_GROUP_NAME\"]\n",
"server_group_name = os.environ[\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_NAME\"]\n",
"server_group_namespace = os.environ[\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_NAMESPACE\"]\n",
"server_group_workers = os.environ[\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_WORKERS\"]\n",
"server_group_service_type = os.environ[\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_SERVICE_TYPE\"]\n",
"server_group_data_size = os.environ[\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_DATA_SIZE\"]\n",
"\n",
"# Optional Values\n",
"server_group_data_class = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_DATA_CLASS\")\n",
"server_group_port = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_PORT\")\n",
"server_group_extensions = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_EXTENSIONS\")\n",
"server_group_cpu_min = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_CPU_MIN\")\n",
"server_group_cpu_max = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_CPU_MAX\")\n",
"server_group_memory_min = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_MEMORY_MIN\")\n",
"server_group_memory_max = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_MEMORY_MAX\")\n",
"server_group_backup_classes = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_BACKUP_CLASSES\")\n",
"server_group_backup_sizes = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_BACKUP_SIZES\")\n",
"server_group_backup_full_interval = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_BACKUP_FULL_INTERVAL\")\n",
"server_group_backup_delta_interval = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_BACKUP_DELTA_INTERVAL\")\n",
"server_group_backup_retention_min = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_BACKUP_RETENTION_MIN\")\n",
"server_group_backup_retention_max = os.environ.get(\"AZDATA_NB_VAR_POSTGRES_SERVER_GROUP_BACKUP_RETENTION_MAX\")"
],
"metadata": {
"azdata_cell_guid": "53769960-e1f8-4477-b4cf-3ab1ea34348b",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Installing PostgreSQL server group**"
],
"metadata": {
"azdata_cell_guid": "90b0e162-2987-463f-9ce6-12dda1267189"
}
},
{
"cell_type": "code",
"source": [
"print (f'Creating a PostgreSQL server group on Azure Arc')\n",
"\n",
"data_class_option = f' --dataClass \"{server_group_data_class}\"' if server_group_data_class else \"\"\n",
"port_option = f' --port \"{server_group_port}\"' if server_group_port else \"\"\n",
"extensions_option = f' --extensions \"{server_group_extensions}\"' if server_group_extensions else \"\"\n",
"cpu_min_option = f' --minCpu \"{server_group_cpu_min}\"' if server_group_cpu_min else \"\"\n",
"cpu_max_option = f' --maxCpu \"{server_group_cpu_max}\"' if server_group_cpu_max else \"\"\n",
"memory_min_option = f' --minMemoryMb \"{server_group_memory_min}\"' if server_group_memory_min else \"\"\n",
"memory_max_option = f' --maxMemoryMb \"{server_group_memory_max}\"' if server_group_memory_max else \"\"\n",
"backup_classes_option = f' --backupClasses \"{server_group_backup_classes}\"' if server_group_backup_classes else \"\"\n",
"backup_sizes_option = f' --backupSizesMb \"{server_group_backup_sizes}\"' if server_group_backup_sizes else \"\"\n",
"backup_full_interval_option = f' --fullBackupInterval \"{server_group_backup_full_interval}\"' if server_group_backup_full_interval else \"\"\n",
"backup_delta_interval_option = f' --deltaBackupInterval \"{server_group_backup_delta_interval}\"' if server_group_backup_delta_interval else \"\"\n",
"backup_retention_min_option = f' --retentionMin \"{server_group_backup_retention_min}\"' if server_group_backup_retention_min else \"\"\n",
"backup_retention_max_option = f' --retentionMax \"{server_group_backup_retention_max}\"' if server_group_backup_retention_max else \"\"\n",
"cmd = f'azdata postgres server create --subscription {subscription} --rg {resource_group_name} --name {server_group_name} --namespace {server_group_namespace} --workers {server_group_workers} --serviceType {server_group_service_type} --dataSizeMb {server_group_data_size}{data_class_option}{port_option}{extensions_option}{cpu_min_option}{cpu_max_option}{memory_min_option}{memory_max_option}{backup_classes_option}{backup_sizes_option}{backup_full_interval_option}{backup_delta_interval_option}{backup_retention_min_option}{backup_retention_max_option}'\n",
"out=run_command()"
],
"metadata": {
"azdata_cell_guid": "4fbaf071-55a1-40bc-be7e-7b9b5547b886"
},
"outputs": [],
"execution_count": null
}
]
}

View File

@@ -0,0 +1,137 @@
{
"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",
"source": [
"![Microsoft](https://raw.githubusercontent.com/microsoft/azuredatastudio/main/extensions/arc/images/microsoft-small-logo.png)\n",
" \n",
"## Deploy Azure SQL DB managed instance on an existing Azure Arc data cluster\n",
" \n",
"This notebook walks through the process of deploying a <a href=\"https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance\">Azure SQL DB managed instance</a> on an existing Azure Arc data cluster.\n",
" \n",
"* Follow the instructions in the **Prerequisites** cell to install the tools if not already installed.\n",
"* Make sure you have the target Azure Arc data cluster already created.\n",
"\n",
"<span style=\"color:red\"><font size=\"3\">Please press the \"Run Cells\" button to run the notebook</font></span>"
],
"metadata": {
"azdata_cell_guid": "e4ed0892-7b5a-4d95-bd0d-a6c3eb0b2c99"
}
},
{
"cell_type": "markdown",
"source": [
"### **Check prerequisites**"
],
"metadata": {
"azdata_cell_guid": "68531b91-ddce-47d7-a1d8-2ddc3d17f3e7"
}
},
{
"cell_type": "code",
"source": [
"import sys,os,json,subprocess\n",
"def run_command():\n",
" print(\"Executing: \" + cmd)\n",
" output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True )\n",
" if output.returncode != 0:\n",
" print(f'Command: {cmd} failed \\n')\n",
" print(f'\\t>>>Error output: {output.stderr.decode(\"utf-8\")}\\n')\n",
" sys.exit(f'exit code: {output.returncode}\\n')\n",
" print(f'Successfully executed: {cmd}')\n",
" print(f'\\t>>>Output: {output.stdout.decode(\"utf-8\")}\\n')\n",
" return output.stdout.decode(\"utf-8\")\n",
"cmd = 'azdata --version'\n",
"out = run_command()\n",
""
],
"metadata": {
"azdata_cell_guid": "749d8dba-3da8-46e9-ae48-2b38056ab7a2",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"#### **Ensure SQL instance name, username, password, subscription id and resource group name**"
],
"metadata": {
"azdata_cell_guid": "68ec0760-27d1-4ded-9a9f-89077c40b8bb"
}
},
{
"cell_type": "code",
"source": [
"# Required Values\n",
"env_var = \"AZDATA_NB_VAR_SQL_INSTANCE_NAME\" in os.environ\n",
"if env_var:\n",
" mssql_instance_name = os.environ[\"AZDATA_NB_VAR_SQL_INSTANCE_NAME\"]\n",
"else:\n",
" sys.exit(f'environment variable: AZDATA_NB_VAR_SQL_INSTANCE_NAME was not defined. Exiting\\n')\n",
"env_var = \"AZDATA_NB_VAR_SQL_PASSWORD\" in os.environ\n",
"if env_var:\n",
" mssql_password = os.environ[\"AZDATA_NB_VAR_SQL_PASSWORD\"]\n",
"else:\n",
" sys.exit(f'environment variable: AZDATA_NB_VAR_SQL_PASSWORD was not defined. Exiting\\n') \n",
"\n",
"# Optional Values\n",
"subscription = os.environ[\"AZDATA_NB_VAR_ARC_SUBSCRIPTION\"] \n",
"resource_group_name = os.environ[\"AZDATA_NB_VAR_ARC_RESOURCE_GROUP_NAME\"]\n"
],
"metadata": {
"azdata_cell_guid": "53769960-e1f8-4477-b4cf-3ab1ea34348b",
"tags": []
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"### **Installing Managed SQL Instance**"
],
"metadata": {
"azdata_cell_guid": "90b0e162-2987-463f-9ce6-12dda1267189"
}
},
{
"cell_type": "code",
"source": [
"print (f'Creating Managed SQL Server instance on Azure Arc')\n",
"\n",
"os.environ[\"MSSQL_SA_PASSWORD\"] = mssql_password\n",
"subscription_option = f' -s \"{subscription}\"' if subscription else \"\"\n",
"resource_group_option = f' -r \"{resource_group_name}\"' if resource_group_name else \"\"\n",
"cmd = f'azdata sql instance create -n {mssql_instance_name}{subscription_option}{resource_group_option}'\n",
"out=run_command()"
],
"metadata": {
"azdata_cell_guid": "4fbaf071-55a1-40bc-be7e-7b9b5547b886"
},
"outputs": [],
"execution_count": null
}
]
}