How To Create An Azure Kubernetes Cluster

Introduction

In this article, we will learn how to create an Azure Kubernetes cluster. In my previous article, we have already seen what Kubernetes and Azure Kubernetes are and we have also learned what are the main features of these services.

There are two ways by we can provide this service.

  1. Using Azure portal
  2. Using Azure CLI

In this article, I'm going to explain how to provide this service through Azure CLI but I will give you a quick introduction of provisioning through the Azure portal also.

Step 1

Log in to the Azure portal and go to the marketplace, search Azure Kubernetes services and click on it.

How to Create an Azure Kubernetes Cluster

Step 2

Click on the Kubernetes cluster.

How to Create an Azure Kubernetes Cluster

Step 3

Create a new “resource group” for this service and enter other details.

How to Create an Azure Kubernetes Cluster

Step 3

Enter cluster name, region, and Kubernetes version.

How to Create an Azure Kubernetes Cluster

Step 4

Choose the node size, and node count (I have chosen 1 but the default is 3) and click on Next.

How to Create an Azure Kubernetes Cluster

Step 5

Go with default settings of “Node Pools” TAB. Node pool is something like IIS Pool under which many nodes can exist. It is showing 1 as I have chosen to create only one node in the last Tab.

How to Create an Azure Kubernetes Cluster

Step 6

Go ahead with the default settings of the “Authentication” Tab.

Note
The system-assigned managed identity authentication method must be used in order to associate an Azure Container Registry.

How to Create an Azure Kubernetes Cluster

Step 7

Go ahead with a default setting of Networking, Integrations and click on Create under the “Review and Create” Tab.

How to Create an Azure Kubernetes Cluster

It will create a new Kubernetes Cluster in Azure. That will be ready to deploy the application in pods of the respective node.

As I explained above, today we will see how we can create an AKS cluster through Azure CLI hence let’s move to that part.

Step 1

Click on Cloud Shell Icon in the top bar. It will automatically connect to the account through which you have logged in to Azure.

How to Create an Azure Kubernetes Cluster

Step 2

The next screen will be shown as below,

How to Create an Azure Kubernetes Cluster

Step 3

Now execute the below command, to create an AKS Cluster. It will take 5-10 min to complete the execution.

Note
E
nsure to generate the SSH keys. This can allow us to log into the cluster if required.

az aks create --resource-group aks-demo-rg --name home-ss-aks001 --node-count 1 --node-vm-size Standard_B2s--generate-ssh-keys

How to Create an Azure Kubernetes Cluster

Step 4

Once the execution is completed, it will give the complete output in JSON format. You can go through that if required.

How to Create an Azure Kubernetes Cluster

Step 5

Now go to the portal and review the resources created under our resource group “aks-demo-rg”.

How to Create an Azure Kubernetes Cluster

Note
When an AKS cluster is created, some other resources are also created along with it, under a different resource group called “MC_aks-demo-rg_home-ss-aks001_centralindia”

I will write another article about these resources, to explain in detail.

How to Create an Azure Kubernetes Cluster

Step 6

Now use the below command to connect with our cluster and execute some kubectl commands to communicate with the cluster.

az aks get-credentials --resource-group aks-demo-rg --name home-ss-aks001

Note
I have created the same name “home-ss-aks001” that has already been created earlier and available in the Kubernetes configuration file, that is why it has asked to overwrite the configuration.

If you are creating a cluster the first time and trying to connect that then this message will not come.

How to Create an Azure Kubernetes Cluster

Step 7

Execute some KubeCTL commands to communicate with our cluster like below.

kubectl get nodes

How to Create an Azure Kubernetes Cluster

We can see that one node is showing in the ready status with its time and version.

Next, we will userdatnd the deployment onto the AKS cluster

Conclusion

We have discussed two methods of creating an AKS cluster in Azure via the portal and Azure CLI. It is quite simple to create the cluster in Azure with just a few commands and it is ready to serve.