AKS Creation - Step by Step Approach
Tags: azure, aks, kubernetes, pods
Published: 2023-02-10 00:24:04

**Step 1 :** Login to portal.azure.com Kubernetes Services -> Create a Kubernetes cluster

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bl8avsobcswhqum01itu.png)


**Step 2** : Enter the mandatory fields
Subscription : Select the subscription
Resource Group : Create one if does not exists / select the existing one
Cluster present configuration : Standard ($$) (selected Standard from the list )
Kubernetes cluster name : srini-aks
Region : (Europe)UK South

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17xdd0dpkg9rdw2m0t7g.png)

**Step 3:** Change the size of the cluster to B2S ( Because cluster should have 4GB of memory)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9sydhro91l5rzau86pbf.png)

**Step 4:** By default Node count range will go to 5 but demo change to 1 then click on Review and Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzgvw1aukv7u6ud4spn7.png)

**Step 5:** View all the changes then click on Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxtprqiv6e7340rh5oxl.png)

**Step 6:** AKS Cluster will take time of 5 to 10 minutes to create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8h55btony8iado14zom.png)

**Step 7 :** Then the newly created cluster will show in Kubernetes services and then click on the cluster : srini-aks

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gocw44awf8cfbph6vk05.png)

**Step 8:** Click on Connect

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5rvp6ymtltdqm0t33e0.png)

**Steps 9:** steps to connect cluster will be shown in the azure portal

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5z0ukbpr399ljso4lf4.png)

- az account set --subscription SubscriptionId
- az aks get-credentials --resource-group devopsTraining --name srini-linux

1. SubscriptionId :  Need to replaced with the subscription id
2. resource group :  Need to update resource group, where you have created cluster
3. name : Name of the cluster

Once you have run the command above to connect to the cluster, you can run any kubectl commands. Here are a few examples of useful commands you can try.

# List all deployments in all namespaces
kubectl get deployments --all-namespaces=true

# List all deployments in a specific namespace
# Format :kubectl get deployments --namespace <namespace-name>
kubectl get deployments --namespace kube-system

# List details about a specific deployment
# Format :kubectl describe deployment <deployment-name> --namespace <namespace-name>
kubectl describe deployment my-dep --namespace kube-system

# List pods using a specific label
# Format :kubectl get pods -l <label-key>=<label-value> --all-namespaces=true
kubectl get pods -l app=nginx --all-namespaces=true

# Get logs for all pods with a specific label
# Format :kubectl logs -l <label-key>=<label-value>
kubectl logs -l app=nginx --namespace kube-system


**Step10 **: Open Cloud Shell or the Azure CLI and run all the commands one by one . Subscription id varies based on your subscription

**Step11 :** During the process of running the commands from step 10
.kube folder will be created under which user the commands ran


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v7u1ryti1cy0b0xyw1h2.png)

**Step12 :** Run Kubectl commands
12.1 Get Nodes
kubectl get nodes
NAME                STATUS  ROLES  AGE  VERSION
aks-agentpool-39508002-vmss000000  Ready  agent  23m  v1.24.9
12.2 kubectl get pods
No resources found in default namespace.
12.3 Create POD
kubectl run srini-nginx --image=nginx
pod/srini-nginx created
12.4 List PODS
kubectl get pods
NAME  READY  STATUS  RESTARTS  AGE
nginx  1/1   Running  0     8s

**Step 13: **Delete the AKS Cluster and it will delete the nodes then the cluster will be deleted in 5 to 10 minutes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqqsksisz3gfbjqgvtes.png)

Wrapup
Step by step approach for creation of AKS K8s cluster and please let me know the comments for this article.

LinkedIn : https://www.linkedin.com/in/srinivasuluparanduru/