Exercise 1: Create An AKS Cluster
Task 1 - Login into your subscription
Login to Azure.
az login
az login
Set 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_GROUP
az group create --location $LOCATION \ --resource-group $RESOURCE_GROUP
Define 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 $LOCATION
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 $LOCATION
The 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_GROUP
az aks get-credentials --name $AKS_NAME \ --resource-group $RESOURCE_GROUP
Confirm the connection to the cluster.
kubectl get nodes
kubectl get nodes
This should return a list of nodes similar to the one below: