Accessing a private AKS cluster using the command invoke
By: Date: 21/04/2023 Categories: azure Tags:

You must establish a connection to the private AKS cluster either through the cluster virtual network, a peer network, or a configured private endpoint in order to access the cluster.

Required prerequisites

  1. There is already a private cluster in place.
  2. Azure CLI version 2.24.0 or later is required.
  3. This role has access to the Microsoft.ContainerService/managedClusters/runcommand/action and the Microsoft.ContainerService/managedClusters/commandResults/read roles on the cluster.

Run a single command with command invoke

As an example:

If you want to run a command on your cluster, run az aks invoke --command

az aks command invoke \
  --resource-group myResourceGroup \
  --name myAKSCluster \
  --command "kubectl get pods -n kube-system"

Run multiple commands with command invoke

If you want to run multiple commands on your cluster, run az aks invoke --command

az aks command invoke \
  --resource-group myResourceGroup \
  --name myAKSCluster \
  --command "helm repo add bitnami https://charts.bitnami.com/bitnami && helm repo update && helm install my-release bitnami/nginx"

For more details- Using command invoke