How To Connect to an Azure Kubernetes Service (AKS) Cluster With Azure CLI and Kubectl

How To Connect to an Azure Kubernetes Service (AKS) Cluster With Azure CLI and Kubectl

ยท

2 min read

In this blog, I will help you access the AKS cluster from your local machine by using the Azure-CLI and Kubectl command.

Prerequisites

It will be good if you have a basic understanding of Azure and Kubernetes, below tool is needed before we processed with installation:

Installation and Configuration Steps

Once both command-line-tool installations are completed, you can log in to your azure account from your local machine by running the below command as it will be needed to connect to the AKS cluster.

az login

check if your cluster is in the same subscription or not, by running the below command az:

account show

If you have more than one subscription then run the below command to set/change the subscription where your cluster is running:

az account set --subscription "subscription-name"

once you are connected to the subscription, the next step is to connect to the AKS cluster within the subscription which is set by using the previous command.

we run the following command to authenticate to our AKS cluster. Make sure you update the resource group name and cluster name:

az aks get-credentials --resource-group "resource-group-name" --name "aks-cluster-name"

Finally, we will be able to connect and manage the AKS cluster by using the Kubectl commands.

I hope this blog helps you and if you have any suggestions/questions, feel free to comment.

ย