How to connect Azure Kubernetes Service(AKS) Cluster and run Kubectl commands

How to connect Azure Kubernetes Service(AKS) Cluster and run Kubectl commands

Below information used to connect to Azure Kubernetes Cluster using Az commands and to run Kubectl commands to collect the cluster performance metrics.
Verify both Azure CLI and Kubectl are configured in AppManager installed server as mentioned in our prerequisites.
First we need to login to the Azure account by configuring Azure subscription and login details. And then we need to connect to Kubernetes Cluster only then we can able to run Kubectl commands.

Steps to connect Azure account:
  1. Open command prompt, run az cloud set --name AzureCloud
To set Azure Government cloud, run az cloud set --name AzureUSGovernment, click here to know more.
  1. To set subscription, run az login --service-principal -u <app-id> -p <password-or-cert> --tenant <tenant>, Refer here for more details.
az login --service-principal -u aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee -p aaaaaaa.bbbbbb~ccccc~ddd-eeeee~fff --tenant aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee

Steps to connect Azure AKS Cluster:
  1. 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.
  1. Open command prompt, run the below command
az account set --subscription aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
  1. 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
  1. az aks get-credentials --resource-group resourcegroupname --name clustername --file <specific_location>
 

Kubectl Commands used in Applications Manager:
  1. All the commands will be appended with  --kubeconfig <FILEPATH>.
  2. If proxy configured, then run the below command by replacing the clustername and proxyurl 
kubectl config set clusters.clustername.proxy-url proxyurl
  1. Below are the list of commands used for kubectl performance metrics data collection.
    1. kubectl get namespaces -o json
    2. kubectl get componentstatuses -o json --all-namespaces
    3. kubectl get nodes -o json
    4. kubectl get pods -o json --all-namespaces
    5. kubectl get services -o json --all-namespaces
    6. kubectl get deployments -o json --all-namespaces
    7. kubectl get persistentvolumes -o json --all-namespaces
    8. kubectl get persistentvolumeclaims -o json --all-namespaces
    9. kubectl describe nodes
If any of the above command fails, then send us the command and its output in a text file.
Reach out to our support team with the text file containing the output to appmanager-support@manageengine.com along with the latest Support Information File (SIF) from Applications Manager with print all logs enabled for analysis.

                    New to ADSelfService Plus?

                      • Related Articles

                      • Azure Kubernetes Service(AKS) Troubleshooting FAQs

                        Azure Kubernetes Service(AKS) monitor can be configured only if you have already added a Microsoft Azure monitor in Applications Manager. Ensure that you have met all the prerequisites for the Microsoft Azure monitor before monitoring Azure ...
                      • Absence of data in the Pods tab or some tabs in the Kubernetes monitor

                        This is a known issue in the older version of Applications Manager, which is fixed in APM v16800. So, we recommend upgrading the Applications Manager to the stable version to properly fix this issue. To collect data for the Kubernetes Monitor, ...
                      • Unable to Add Kubernetes Monitor

                        If you are having trouble adding a Kubernetes monitor in Applications Manager, ensure that the the prerequisites have been met: Verify whether you can establish an SSH connection to the Kubernetes server from the APM installed machine. Use the ...
                      • Microsoft Azure - FAQ

                        1. What happens to the Azure monitor in Applications Manager when you delete any of the supported services from the Azure portal? When you perform a delete operation on any of the supported Azure resources in the Azure portal, the respective monitor ...
                      • How to add an APM Insight Java agent in Kubernetes via InitContainers?

                        Step 1. Create a secret to access the APM Insight license key in your application namespace: kubectl create secret generic app-secret --from-literal=s247licensekey='your_APMInsight_license_key' -n petclinic The license key can be obtained from the ...