简体   繁体   中英

How to access azure k8s cluster without run Invoke Command?

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"

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:

  • 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.

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.

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM