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
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.
Pre-req Azure Cli must be installed.
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.
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.
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
You have a few options to do so, such as :
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.