Skip to content

Commit 487f6b8

Browse files
authored
separate SP creation (#749)
* separate SP creation separated Service Principal creation of aks due to issues on some machines with integrated SP creation fixed typo in README * Update deploy-sql-big-data-aks.py removed JSON output
1 parent 1d93e1e commit 487f6b8

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

samples/features/sql-big-data-cluster/deployment/aks/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Using this sample Python script, you will deploy a Kubernetes cluster in Azure u
99
1. Install latest version of [az cli](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
1010
1. Running the script will require: [python minimum version 3.0](https://www.python.org/downloads)
1111
1. Install the latest version of [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
12-
1. Ensure you have installed `mssqlctl` CLI and its prerequisites:
12+
1. Ensure you have installed `azdata` CLI (previously named mssqlctl) and its prerequisites:
1313
- Install [pip3](https://pip.pypa.io/en/stable/installing/).
1414
- Install/update requests package. Run the command below using elevated priviledges (sudo or admin cmd window):
1515
```
1616
python -m pip install requests
1717
python -m pip install requests --upgrade
1818
```
19-
- Install latest version of the cluster management tool **azdata** (previously named mssqlctl) using below command. Run the command below using elevated priviledges (sudo or admin cmd window):
19+
- Install latest version of the cluster management tool **azdata** using below command. Run the command below using elevated privileges (sudo or admin cmd window):
2020
```
2121
pip3 install -r https://aka.ms/azdata
2222
```

samples/features/sql-big-data-cluster/deployment/aks/deploy-sql-big-data-aks.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
# Run `az login` at least once BEFORE running this script
77
#
88

9-
from subprocess import check_output, CalledProcessError, STDOUT, Popen, PIPE
9+
from subprocess import check_output, CalledProcessError, STDOUT, Popen, PIPE, getoutput
10+
from time import sleep
1011
import os
1112
import getpass
13+
import json
1214

1315
def executeCmd (cmd):
1416
if os.name=="nt":
@@ -57,16 +59,27 @@ def executeCmd (cmd):
5759
# os.environ['DOCKER_PASSWORD']=DOCKER_PASSWORD
5860
os.environ['ACCEPT_EULA']="Yes"
5961

60-
print ("Set azure context to subcription: "+SUBSCRIPTION_ID)
62+
print ("Set azure context to subscription: "+SUBSCRIPTION_ID)
6163
command = "az account set -s "+ SUBSCRIPTION_ID
6264
executeCmd (command)
6365

6466
print ("Creating azure resource group: "+GROUP_NAME)
6567
command="az group create --name "+GROUP_NAME+" --location "+AZURE_REGION
6668
executeCmd (command)
6769

70+
SP_NAME = AZURE_REGION + '_' + GROUP_NAME + '_' + CLUSTER_NAME
71+
print ("Creating Service Principal: "+SP_NAME)
72+
command = "az ad sp create-for-rbac --skip-assignment --name http://" + SP_NAME
73+
SP_RESULT=getoutput(command)
74+
SP_JSON = json.loads(SP_RESULT[SP_RESULT.find("{"):])
75+
SP_PRINCIPAL = (SP_JSON['appId'])
76+
SP_PW = (SP_JSON['password'])
77+
78+
# Waiting for 10 seconds for the SP to sync
79+
sleep(10)
80+
6881
print("Creating AKS cluster: "+CLUSTER_NAME)
69-
command = "az aks create --name "+CLUSTER_NAME+" --resource-group "+GROUP_NAME+" --generate-ssh-keys --node-vm-size "+VM_SIZE+" --node-count "+AKS_NODE_COUNT
82+
command = "az aks create --name "+CLUSTER_NAME+" --resource-group "+GROUP_NAME+" --generate-ssh-keys --node-vm-size "+VM_SIZE+" --node-count "+AKS_NODE_COUNT+ " --service-principal " + SP_PRINCIPAL + " --client-secret " + SP_PW
7083
executeCmd (command)
7184

7285
command = "az aks get-credentials --overwrite-existing --name "+CLUSTER_NAME+" --resource-group "+GROUP_NAME+" --admin"

0 commit comments

Comments
 (0)