skip to Main Content

I have an AKS cluster and it’s private. I want to access it from my local and i added necessary commands for kubeconfig. Now, i can list pods with invoke command. But i want to access directly like kubectl get pods command. (i dont want do alias)

az aks command invoke 
  --resource-group rg-network-spokes 
  --name aks_dev_cluster 
  --command "kubectl get pods -A"

3

Answers


  1. You can download the kubeconfig file in this path "/home/.kube/config" and now you are good to go.

    Or, Use Kubernetes Lens to manage from a UI.

    Login or Signup to reply.
    1. Your AKS cluster is private you must be accessing it via VPN right? You can connect to VPN to access the cluster over private network. You can download the kubeconfig via this command.

    Pre-req Azure Cli must be installed.

    az aks get-credentials --resource-group my-rg --name my-aks --file my-aks-kubeconfig-ss
    

    It will generate a kubeconfig for you with name my-aks-kubeconfig-ss. You can copy this config and paste inside .kube/ folder or your choice. You can access AKS cluster from Lens via UI mode.

    1. Second option is to use lens.

    Install lens. After installation lens press ctrl + shift + A and a windows will open asking for kubeconfig. Copy the content from my-aks-kubeconfig-ss and paste it here. Bingo your cluster is added inside Lens.

    Login or Signup to reply.
  2. If your aks cluster is private, it means its controle plane is not exposed on internet and therefore you can not use kubectl to interact with the API without being into the same vnet as your cluster

    enter image description here

    You have a few options to do so, such as :

    • Create a VM in the same VNET as your cluster and install kubectl client
    • Create a VPN to connect your computer on the aks’s network

    If you are starting with Azure, I would suggest going with the first option as setting up a VPN can be a bit more tedious.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search