Last active
March 3, 2021 18:08
-
-
Save robece/7ae9ccc299c4fac16f3e428d03e7b42d to your computer and use it in GitHub Desktop.
AKS Powershell deployment script
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
# NOTE: before run this script ensure you are logged in Azure by using "az login" command. | |
$DeploymentAlias = Read-Host -Prompt "Introduce a lowercase unique alias for your deployment (max length suggested of 9 chars)" | |
$ResourceGroupName = "$($DeploymentAlias)-group" | |
$Location = "westus2" | |
$AKSClusterName = "$($DeploymentAlias)ks" | |
$AKSK8sVersion = "1.17.13" | |
$ContainerRegistryName = "$($DeploymentAlias)cr" | |
Write-Host "**********************************************************************" | |
Write-Host " CREATING: GENERAL RESOURCE GROUP" | |
Write-Host "" | |
Write-Host " Description:" | |
Write-Host "" | |
Write-Host " A container that holds related resources for an Azure solution." | |
Write-Host "**********************************************************************" | |
# create cluster resource group | |
az group create --name $ResourceGroupName --location $Location | |
Write-Host "**********************************************************************" | |
Write-Host " CREATING: CONTAINER REGISTRY" | |
Write-Host "" | |
Write-Host " Description:" | |
Write-Host "" | |
Write-Host " A registry of Docker and Open Container Initiative (OCI) images, with" | |
Write-Host " support for all OCI artifacts." | |
Write-Host "**********************************************************************" | |
# create acr | |
az acr create -n $ContainerRegistryName -g $ResourceGroupName --sku basic --admin-enabled true | |
# get acr id | |
$ACR_ID = $(az acr show -n $ContainerRegistryName -g $ResourceGroupName --query id -o tsv) | |
Write-Host "**********************************************************************" | |
Write-Host " CREATING: KUBERNETES SERVICE" | |
Write-Host "" | |
Write-Host " Description:" | |
Write-Host "" | |
Write-Host " Highly available, secure, and fully managed Kubernetes service." | |
Write-Host "**********************************************************************" | |
# create cluster | |
az aks create --name $AKSClusterName ` | |
--resource-group $ResourceGroupName ` | |
--node-count 3 --kubernetes-version $AKSK8sVersion ` | |
--attach-acr $ACR_ID ` | |
--generate-ssh-keys ` | |
--vm-set-type AvailabilitySet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment