Created
February 26, 2019 15:38
-
-
Save avinashseth/43e294ebef0a2f5ab045ddfa201552b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SP_PASSWORD=your_password | |
| RESOURCE_GROUP_NAME=your_resource_rg | |
| CLUSTER_NAME=your_cluster | |
| LOCATION=eastus | |
| # Create a resource group | |
| az group create --name $RESOURCE_GROUP_NAME --location $LOCATION | |
| # Create a virtual network and subnet | |
| az network vnet create \ | |
| --resource-group $RESOURCE_GROUP_NAME \ | |
| --name myVnet \ | |
| --address-prefixes 10.0.0.0/8 \ | |
| --subnet-name your_subnet \ | |
| --subnet-prefix 10.240.0.0/16 | |
| # Create a service principal and read in the application ID | |
| SP_ID=$(az ad sp create-for-rbac --password $SP_PASSWORD --skip-assignment --query [appId] -o tsv) | |
| # Wait 15 seconds to make sure that service principal has propagated | |
| echo "Waiting for service principal to propagate..." | |
| # Get the virtual network resource ID | |
| VNET_ID=$(az network vnet show --resource-group $RESOURCE_GROUP_NAME --name myVnet --query id -o tsv) | |
| # Assign the service principal Contributor permissions to the virtual network resource | |
| az role assignment create --assignee $SP_ID --scope $VNET_ID --role Contributor | |
| # Get the virtual network subnet resource ID | |
| SUBNET_ID=$(az network vnet subnet show --resource-group $RESOURCE_GROUP_NAME --vnet-name myVnet --name myAKSSubnet --query id -o tsv) | |
| # Create the AKS cluster and specify the virtual network and service principal information | |
| # Enable network policy using the `--network-policy` parameter | |
| az aks create \ | |
| --resource-group $RESOURCE_GROUP_NAME \ | |
| --name $CLUSTER_NAME \ | |
| --node-count 1 \ | |
| --kubernetes-version 1.12.4 \ | |
| --generate-ssh-keys \ | |
| --network-plugin azure \ | |
| --service-cidr 10.0.0.0/16 \ | |
| --dns-service-ip 10.0.0.10 \ | |
| --docker-bridge-address 172.17.0.1/16 \ | |
| --vnet-subnet-id $SUBNET_ID \ | |
| --service-principal $SP_ID \ | |
| --client-secret $SP_PASSWORD \ | |
| --network-policy calico |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment