Estimated Duration: 30 minutes
This exercise will cover deployment of a basic AKS cluster. This will be use as the basis for most subsequent exercises.
NOTE: You need to fulfill these requirements to complete this exercise.
-
Select the region closest to your location. You can use eastus2 for United States workshops, westeurope for European workshops. Other regions include: eastus, westus, canadacentral, westeurope, centralindia, australiaeast
-
Set your initials.
INITIALS="abc"
-
Define global variables (adjust location value accordingly)
RG=aks-$INITIALS-rg LOCATION=eastus2
-
Create Resource Group.
az group create --location $LOCATION \ --resource-group $RG
ACR will be used in subsequent labs
ACR_NAME=acr$INITIALS$RANDOM
az acr create -n $ACR_NAME -g $RG --sku Standard
-
Define variables for AKS cluster.
CLUSTER_NAME=aks-$INITIALS echo "AKS Cluster Name: $CLUSTER_NAME"
-
Create a simple AKS cluster with 2 nodes, attaching ACR and using a specific kubernetes version:
KUBERNETES_VERSION='1.29.9' az aks create --name $CLUSTER_NAME \ --resource-group $RG \ --generate-ssh-keys \ --node-count 2 \ --attach-acr $ACR_NAME \ --kubernetes-version $KUBERNETES_VERSION
NOTE: The creation process will take 5-10 minutes.
-
Once complete, connect the cluster to your local client machine.
az aks get-credentials --name $CLUSTER_NAME \ --resource-group $RG
-
Confirm the connection to the cluster.
kubectl get nodes
The manifests/aks-helloworld-basic.yaml
file contains a Deployment manifest.
-
Run the following commands to create a namespace and deploy hello world application:
kubectl create namespace helloworld kubectl apply -f manifests/aks-helloworld-basic.yaml -n helloworld
-
Run the following command to verify deployment and service has been created. Re-run command until pod shows a
STATUS
of Running andEXTERNAL-IP
of the service shows a value.kubectl get all -n helloworld
-
Copy the external IP value or use this command to save it into a variable:
EXTERNAL_IP=$(kubectl get svc aks-helloworld -n helloworld -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
-
Run curl command to confirm the service is reachable on that address:
curl -L http://$EXTERNAL_IP