In this blog post, I will show you how to connect to an Azure Kubernetes Service (AKS) cluster using Azure CLI and run Kubectl commands.
In order to fully manage an AKS cluster and deploy applications and services, we need to utilise Kubectl which is the command-line tool for Kubernetes.
In an Azure deployment on AKS, we can access the kubectl command-line with Azure CLI and I will show you how to do it.
You also need to install Azure CLI on your Windows or macOS machine.
Connect and Install Kubectl
To connect to an Azure AKS cluster first we need to login to Azure using the following command:
If you have more than one subscription set it using the following command:
az account set --subscription subname
After login to Azure, install the Kubectl command line tools plug in for Azure CLI using the following line:
az aks install-cli
And finally, we run the following command to authenticate to our AKS cluster. Make sure you fill in the resource group name of your cluster and your cluster name:
az aks get-credentials --resource-group RGNAME --name CLUSTERNAME
From here you can type kubectl and access the help file and start managing your AKS cluster.