AKS Cluster Setup

K8s Installation

  1. Environment Variables

RESOURCE_GROUP_NAME=myResourceGroup-NP
CLUSTER_NAME=myAKSCluster
LOCATION=eastus
  1. Create a resource group

az group create --name $RESOURCE_GROUP_NAME --location $LOCATION
  1. Create a virtual network and subnet

az network vnet create \
--resource-group $RESOURCE_GROUP_NAME \
--name myVnet \
--address-prefixes 10.0.0.0/8 \
--subnet-name myAKSSubnet \
--subnet-prefix 10.240.0.0/16
  1. Create a service principal and read in the application ID

SP=$(az ad sp create-for-rbac --output json)
SP_ID=$(echo $SP | jq -r .appId)
SP_PASSWORD=$(echo $SP | jq -r .password)
echo $SP_PASSWORD

Copy the Above Password and Store it in some place. In Case of Issues, this password will help for troubleshooting

Wait 30 seconds to make sure that service principal has propagated

  1. Get the virtual network resource ID

  1. Assign the service principal Contributor permissions to the virtual network resource

  1. Get the virtual network subnet resource ID

  1. Create the AKS cluster and specify the virtual network, service principal information, and azure for the network plugin and network policy.

  1. This command downloads credentials and configures the Kubernetes CLI to use them:

  1. Check the K8s Cluster is working fine or not.

Get the Kube Config file from Azure Shell to Windows Computer.

You will get a link as Output and Open the URL in the browser.

You can then download the File on to Windows Laptop / Desktop.

COpy this file and paste it C Drive > Users > YOUR NAME > .KUBE folder

Last updated

Was this helpful?