Exercise 1: Create An AKS Cluster
Task 1 - Login into your subscription
Login to Azure.
az loginaz loginSet the current subscription.
az account set --subscription "<your subscription name or ID>"az account set --subscription "<your subscription name or ID>"
Task 2 - Define variables and create resource group
Select the region closest to your location. Use ‘eastus’ for United States workshops, ‘westeurope’ for European workshops. Ask your instructor for other options in your region.
Set your initials.
$YOUR_INITIALS="abc"YOUR_INITIALS="abc"Define global variables
$INITIALS="$($YOUR_INITIALS)".ToLower() $RESOURCE_GROUP="azure-$($INITIALS)-rg" $LOCATION="westeurope"INITIALS=$(echo $YOUR_INITIALS | tr '[:upper:]' '[:lower:]') RESOURCE_GROUP="azure-${INITIALS}-rg" LOCATION="westeurope"Set the VM SKU
$VM_SKU="Standard_D4s_v5"VM_SKU="Standard_D4s_v5"
Task 3 - Create resource group and a basic cluster using Azure CLI
Create Resource Group.
az group create --location $LOCATION ` --resource-group $RESOURCE_GROUPaz group create --location $LOCATION \ --resource-group $RESOURCE_GROUPDefine variables for AKS cluster.
$AKS_NAME="aks-$($INITIALS)" Write-Host "AKS Cluster Name: $AKS_NAME"AKS_NAME="aks-${INITIALS}" echo "AKS Cluster Name: $AKS_NAME"Create a simple AKS cluster.
az aks create --node-count 2 ` --generate-ssh-keys ` --node-vm-size $VM_SKU ` --name $AKS_NAME ` --enable-addons monitoring,azure-keyvault-secrets-provider ` --enable-app-routing ` --network-plugin azure ` --network-plugin-mode overlay ` --pod-cidr 192.168.0.0/16 ` --network-dataplane cilium ` --resource-group $RESOURCE_GROUP ` --location $LOCATIONaz aks create --node-count 2 \ --generate-ssh-keys \ --node-vm-size $VM_SKU \ --name $AKS_NAME \ --enable-addons monitoring,azure-keyvault-secrets-provider \ --enable-app-routing \ --network-plugin azure \ --network-plugin-mode overlay \ --pod-cidr 192.168.0.0/16 \ --network-dataplane cilium \ --resource-group $RESOURCE_GROUP \ --location $LOCATIONThe creation process will take able 5-10 minutes.
Once complete, connect the cluster to your local client machine.
az aks get-credentials --name $AKS_NAME ` --resource-group $RESOURCE_GROUPaz aks get-credentials --name $AKS_NAME \ --resource-group $RESOURCE_GROUPConfirm the connection to the cluster.
kubectl get nodeskubectl get nodes
This should return a list of nodes similar to the one below:
