Exercise Overview: This exercise guides users through the process of creating an Azure Kubernetes Service (AKS) cluster using the Kubenet network plugin and a Standard Load Balancer. It covers the creation of a resource group, a service principal, and the AKS cluster itself. The users will learn how to configure and manage a basic AKS cluster with a focus on networking components.
- Azure Subscription
- Azure CLI
- SSH Key Pair
Solution
Creates an Azure Resource Group for organizing and managing resources.
az group create --location westeurope --resource-group demo-weu-rg
Generates a Service Principal for AKS with the necessary permissions.
az ad sp create-for-rbac --skip-assignment -n "spn-aks"
NOTE: Replace placeholders in --subscription
, --service-principal
, and --client-secret
with actual values.
Deploys an AKS cluster with specified configurations.
az aks create \
--location westeurope \
--subscription <Your-Subscription-ID> \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--ssh-key-value $HOME/.ssh/id_rsa.pub \
--service-principal "<Your-Service-Principal-ID>" \
--client-secret "<Your-Client-Secret>" \
--network-plugin kubenet \
--load-balancer-sku standard \
--outbound-type loadBalancer \
--node-vm-size Standard_B2s \
--node-count 1 \
--tags 'ENV=Demo' 'OWNER=Corporation Inc.'
Retrieves and merges the AKS cluster's kubeconfig into the local environment.
az aks get-credentials \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--admin
Check if Our AKS is Up and Running
Create an example deployment
kubectl create deployment nginx --image=nginx
kubectl get po
Deletes the resource group and associated resources.
az group delete -n demo-weu-rg --yes --no-wait
Exercise Overview: This exercise instructs users on creating an AKS cluster using an existing Virtual Network (VNET) and subnets. It covers the creation of a resource group, a service principal, and the AKS cluster itself, emphasizing integration with Azure Container Instances (ACI). Users will learn to leverage an existing network infrastructure for AKS deployment.
- Azure Subscription
- Azure CLI
- SSH Key Pair
- Existing VNET
Solution
Creates an Azure Resource Group for organizing and managing resources.
az group create --location westeurope --resource-group demo-weu-rg
Generates a Service Principal for AKS with the necessary permissions.
az ad sp create-for-rbac --skip-assignment -n "spn-aks"
Creates an Azure Virtual Network (VNET) and two subnets: pod-subnet
and node-subnet
.
az network vnet create \
--resource-group demo-weu-rg \
--name MyVnet \
--address-prefixes 10.0.0.0/8 \
--output none
az network vnet subnet create \
--resource-group demo-weu-rg \
--vnet-name MyVnet \
--name pod-subnet \
--address-prefixes 10.242.0.0/16 \
--output none
az network vnet subnet create \
--resource-group demo-weu-rg \
--vnet-name MyVnet \
--name node-subnet \
--address-prefixes 10.243.0.0/16 \
--output none
Retrieves the subnet IDs for further use in AKS cluster creation.
az network vnet subnet show \
--resource-group demo-weu-rg \
--vnet-name MyVnet \
--name pod-subnet \
--query id \
--output tsv
az network vnet subnet show \
--resource-group demo-weu-rg \
--vnet-name MyVnet \
--name node-subnet \
--query id \
--output tsv
NOTE: Replace placeholders in --service-principal
, and --client-secret
with actual values.
Deploys an AKS cluster using an existing VNET and subnets, with SSH RSA key and Azure Container Instances (ACI) integration.
az aks create \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--vm-set-type VirtualMachineScaleSets \
--node-vm-size Standard_B2s \
--load-balancer-sku standard \
--ssh-key-value $HOME/.ssh/id_rsa.pub \
--service-principal "<Your-Service-Principal-ID>" \
--client-secret "<Your-Client-Secret>" \
--network-plugin "azure" \
--network-policy "calico" \
--vnet-subnet-id "node-subnet" \
--pod-subnet-id "pod-subnet" \
--node-count 1 \
--max-pods 110
--tags 'ENV=Demo' 'OWNER=Corporation Inc.'
Retrieves and merges the AKS cluster's kubeconfig into the local environment.
az aks get-credentials \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--admin
Check if Our AKS is Up and Running
Create an example deployment
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --type=ClusterIP --name=my-service
kubectl get po
Deletes the resource group and associated resources.
az group delete -n demo-weu-rg --yes --no-wait