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
- There is already a private cluster in place.
- Azure CLI version 2.24.0 or later is required.
- This role has access to the
Microsoft.ContainerService/managedClusters/runcommand/action
and theMicrosoft.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