|
| 1 | +# |
| 2 | +# Prerequisites: |
| 3 | +# |
| 4 | +# Azure CLI (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli), python3 (https://www.python.org/downloads), mssqlctl CLI (pip3 install --index-url https://private-repo.microsoft.com/python/ctp-2.0 mssqlctl ) |
| 5 | +# |
| 6 | +# Run `az login` at least once BEFORE running this script |
| 7 | +# |
| 8 | + |
| 9 | +from subprocess import check_output, CalledProcessError, STDOUT, Popen, PIPE |
| 10 | +import os |
| 11 | + |
| 12 | +def executeCmd (cmd): |
| 13 | + if os.name=="nt": |
| 14 | + process = Popen(cmd.split(),stdin=PIPE, shell=True) |
| 15 | + else: |
| 16 | + process = Popen(cmd.split(),stdin=PIPE) |
| 17 | + stdout, stderr = process.communicate() |
| 18 | + if (stderr is not None): |
| 19 | + raise Exception(stderr) |
| 20 | + |
| 21 | +# |
| 22 | +# MUST INPUT THESE VALUES!!!!! |
| 23 | +# |
| 24 | +SUBSCRIPTION_ID = input("Provide your Azure subscription ID:") |
| 25 | +GROUP_NAME = input("Provide Azure resource group name to be created:") |
| 26 | +DOCKER_USERNAME = input("Provide your Docker username:") |
| 27 | +DOCKER_PASSWORD = input("Provide your Docker password:") |
| 28 | + |
| 29 | +# |
| 30 | +# Optionally change these configuration settings |
| 31 | +# |
| 32 | +AZURE_REGION=input("Provide Azure region - Press ENTER for using `westus`:") or "westus" |
| 33 | +VM_SIZE=input("Provide VM size for the AKS cluster - Press ENTER for using `Standard_DS3_v2`:") or "Standard_DS3_v2" |
| 34 | +AKS_NODE_COUNT=input("Provide number of worker nodes for AKS cluster - Press ENTER for using `2`:") or "2" |
| 35 | +#This is both Kubernetes cluster name and SQL Big Data cluster name |
| 36 | +CLUSTER_NAME=input("Provide name of AKS cluster and SQL big data cluster - Press ENTER for using `sqlbigdata`:") or "sqlbigdata" |
| 37 | +#This password will be use for Controller user, Knox user and SQL Server Master SA accounts |
| 38 | +PASSWORD=input("Provide password to be used for Controller user, Knox user and SQL Server Master SA accounts - Press ENTER for using `MySQLBigData2019`:") or "MySQLBigData2019" |
| 39 | +CONTROLLER_USERNAME=input("Provide username to be used for Controller user - Press ENTER for using `admin`:") or "admin" |
| 40 | + |
| 41 | +# |
| 42 | +DOCKER_REGISTRY="private-repo.microsoft.com" |
| 43 | +DOCKER_REPOSITORY="mssql-private-preview" |
| 44 | +DOCKER_IMAGE_TAG="latest" |
| 45 | + |
| 46 | +print ('Setting environment variables') |
| 47 | +os.environ['MSSQL_SA_PASSWORD'] = PASSWORD |
| 48 | +os.environ['CONTROLLER_USERNAME'] = CONTROLLER_USERNAME |
| 49 | +os.environ['CONTROLLER_PASSWORD'] = PASSWORD |
| 50 | +os.environ['KNOX_PASSWORD'] = PASSWORD |
| 51 | +os.environ['DOCKER_REGISTRY'] = DOCKER_REGISTRY |
| 52 | +os.environ['DOCKER_REPOSITORY'] = DOCKER_REPOSITORY |
| 53 | +os.environ['DOCKER_USERNAME']=DOCKER_USERNAME |
| 54 | +os.environ['DOCKER_PASSWORD']=DOCKER_PASSWORD |
| 55 | +os.environ['DOCKER_EMAIL']=DOCKER_USERNAME |
| 56 | +os.environ['DOCKER_IMAGE_TAG']=DOCKER_IMAGE_TAG |
| 57 | +os.environ['DOCKER_IMAGE_POLICY']="IfNotPresent" |
| 58 | +os.environ['DOCKER_PRIVATE_REGISTRY']="1" |
| 59 | +os.environ['CLUSTER_PLATFORM']="aks" |
| 60 | +os.environ['ACCEPT_EULA']="Y" |
| 61 | + |
| 62 | +print ("Set azure context to subcription: "+SUBSCRIPTION_ID) |
| 63 | +command = "az account set -s "+ SUBSCRIPTION_ID |
| 64 | +executeCmd (command) |
| 65 | + |
| 66 | +print ("Creating azure resource group: "+GROUP_NAME) |
| 67 | +command="az group create --name "+GROUP_NAME+" --location "+AZURE_REGION |
| 68 | +executeCmd (command) |
| 69 | + |
| 70 | +print("Creating AKS cluster: "+CLUSTER_NAME) |
| 71 | +command = "az aks create --name "+CLUSTER_NAME+" --resource-group "+GROUP_NAME+" --generate-ssh-keys --node-vm-size "+VM_SIZE+" --node-count "+AKS_NODE_COUNT+" --kubernetes-version 1.10.7" |
| 72 | +executeCmd (command) |
| 73 | + |
| 74 | +command = "az aks get-credentials --name "+CLUSTER_NAME+" --resource-group "+GROUP_NAME+" --admin" |
| 75 | +executeCmd (command) |
| 76 | + |
| 77 | +print("Creating SQL Big Data cluster:" +CLUSTER_NAME) |
| 78 | +command="mssqlctl create cluster "+CLUSTER_NAME |
| 79 | +executeCmd (command) |
| 80 | + |
| 81 | +print("") |
| 82 | +print("SQL Server big data cluster connection endpoints: ") |
| 83 | +print("SQL Server master instance:") |
| 84 | +command="kubectl get service service-master-pool-lb -o=custom-columns=""IP:.status.loadBalancer.ingress[0].ip,PORT:.spec.ports[0].port"" -n "+CLUSTER_NAME |
| 85 | +executeCmd(command) |
| 86 | +print("") |
| 87 | +print("HDFS/KNOX:") |
| 88 | +command="kubectl get service service-security-lb -o=custom-columns=""IP:status.loadBalancer.ingress[0].ip,PORT:.spec.ports[0].port"" -n "+CLUSTER_NAME |
| 89 | +executeCmd(command) |
| 90 | +print("") |
| 91 | +print("Cluster administration portal (https://<ip>:<port>):") |
| 92 | +command="kubectl get service service-proxy-lb -o=custom-columns=""IP:status.loadBalancer.ingress[0].ip,PORT:.spec.ports[0].port"" -n "+CLUSTER_NAME |
| 93 | +executeCmd(command) |
| 94 | +print("") |
0 commit comments