How to connect Azure Kubernetes Service(AKS) Cluster and run Kubectl commands
Login to the Azure account
- To set the Azure Cloud type for the Azure CLI. Open command prompt, run the below command:
- az cloud set --name <CloudType>
- For the CloudType, use the below values accordingly:
- Azure Global: AzureCloud
- Azure US Gov Cloud: AzureUSGovernment
- Azure China: AzureChinaCloud
- To login to the Azure subscription, runthe below command:
- az login --service-principal -u <APP_ID> -p <CLIENT_SECRET> --tenant <TENANT_ID>, Refer here for more details.
- Format: az login --service-principal -u aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee -p aaaaaaa.bbbbbb~ccccc~ddd-eeeee~fff --tenant aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
Login and connect to Azure AKS Cluster:
a. Generate kubeconfig file for the cluster
- Go to Azure Portal -> Kubernetes Services -> Select the required Cluster -> Overview -> Connect to find the entire command for the specific cluster itself or follow the below commands one by one by replacing with subscription Id, cluster name and resource group name.
- Open command prompt, run the below command
az account set --subscription aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
- To generate kubeconfig file, run the below command

az aks get-credentials --resource-group resourcegroupname --name clustername

Above command will create the kubeconfig file in the user root directory. To get kubeconfig file in the specific location, use below command
- az aks get-credentials --resource-group resourcegroupname --name clustername --file <specific_location>
b. Connect and run kubectl commands
- (Optional) To bypass interactive login for kubectl commands:
kubelogin convert-kubeconfig -l azurecli --kubeconfig <FILEPATH>- Execute the below commands to verify the connectivity to the cluster, replace <FILEPATH> with the path where the KUBECONFIG file is created:
kubectl get nodes --kubeconfig <FILEPATH>
kubectl get pods -A --kubeconfig <FILEPATH>
List of kubectl commands used in Applications Manager
All the commands will be appended with --kubeconfig <FILEPATH>.
If proxy configured, then run the below command by replacing the clustername and proxyurl
kubectl config set clusters.clustername.proxy-url proxyurl
Below are the list of commands used for kubectl performance metrics data collection.
kubectl get namespaces -o json
kubectl get componentstatuses -o json --all-namespaces
kubectl get nodes -o json
kubectl get pods -o json --all-namespaces
kubectl get services -o json --all-namespaces
kubectl get deployments -o json --all-namespaces
kubectl get persistentvolumes -o json --all-namespaces
kubectl get persistentvolumeclaims -o json --all-namespaces
kubelogin convert-kubeconfig -l azurecli - Only used for Microsoft Entra ID authentication
List of Azure CLI commands used in Applications Manager
- az version
- az cloud set --name <cloud-type>
- az account set --subscription <subscription-id>
- az login -u <useremail> -p <password> (OR)
- az login --service-principal -u <client-id> -p <client-secret> --tenant <tenant-id>
- az aks get-credentials --resource-group <resource-group-name> --name <cluster-name> --file <kubeconfig-file>

- Latest Support Information File (SIF), ensuring that 'print all logs' is enabled.
- Command: az --version (To login to Azure account) --> Sample Output (For windows 10): azure-cli/2.31.0 Python/3.8.9 Windows/10 exe/AMD64 prompt/off)
- Command: kubectl version --client (To connect to EKS cluster) --> Sample Output starts with: Client Version: v1.23.2
- Check if the Applications Manager installed user has permission to access installed kubectl/azure-cli by verifying prerequisites mentioned above.
- Screenshot of network configuration in Azure portal > Kubernetes services > Networking.
- Connect to the cluster (refer this KB) and execute the below commands and get the output:
- kubectl get nodes
- kubectl get pods -A
- If Microsoft Entra ID authentication is used out of the three supported modes, send the screenshot of the configuration of the user for the Kubernetes cluster.
- For Example, if you chose 'Microsoft Entra ID authentication with Kubernetes RBAC', send the following details:
-


- Screenshot of the owners of the groups.
- Screenshot of the IAM role binding of the Kubernetes cluster from the prerequisites.
New to ADSelfService Plus?