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 ADManager Plus?

                  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

                      To collect data for the Kubernetes Monitor, Applications Manager uses the SSH protocol to connect to the Kubernetes server and execute kubectl commands. However, a timeout issue may occur while collecting data if the environment has a large number of ...
                    • 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 ...
                    • Adding APM Insight Java agent in Kubernetes via InitContainers

                      Step 1: Create a secret for the Site24x7 license key in your application namespace. You can obtain the license key from Applications Manager under APM tab Example: kubectl create secret generic app-secret ...
                    • Setup Applications Manager as Service in Ubuntu 16 and above

                      From v16140 : Support to install and start Applications Manager as a wrapper service in Linux platforms is provided within the product. For more information, see Starting Applications Manager as a Linux Service. Follow the steps mentioned below to ...