AKS node access using kubectl debug Pod
You need to access your AKS nodes and you don’t have the possibility to use SSH?
Don’t worry, it’s easy as using kubectl debug
!
So, of course you need to have access to your AKS cluster API. In this example we will access it using kubectl
.
Step 1: Get the Node Name
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
aks-nodepool1-12121212-vmss000000 Ready <none> 8d v1.29.8 10.10.10.5 <none> Ubuntu 22.04.4 LTS 5.15.0-1071-azure containerd://1.7.20-1
aks-nodepool1-12121212-vmss000001 Ready <none> 8d v1.29.8 10.10.10.6 <none> Ubuntu 22.04.4 LTS 5.15.0-1071-azure containerd://1.7.20-1
aks-nodepool2-13131313-vmss000000 Ready <none> 8d v1.29.8 10.10.10.7 <none> Ubuntu 22.04.4 LTS 5.15.0-1071-azure containerd://1.7.20-1
aks-nodepool2-13131313-vmss000001 Ready <none> 8d v1.29.8 10.10.10.12 <none> Ubuntu 22.04.4 LTS 5.15.0-1071-azure containerd://1.7.20-1
Identify on which node you want to connect and then run the Microsoft busybox image on it.
kubectl debug node/aks-nodepool1-12121212-vmss000000 -it --image=mcr.microsoft.com/cbl-mariner/busybox:2.0
Now you are connected to the Busybox that is running on your AKS node.
if you specifically need an image with azure cli installed on it, you need to run the following image.
kubectl debug node/aks-nodepool1-12121212-vmss000000 -it --image=mcr.microsoft.com/azure-cli:cbl-mariner2.0
Step 2: Access the Node OS
To access the node OS, you will need to chroot
.
chroot /host
Now you can debug image pull issues, network access issues and others using the default binaries installed on the node ;-)
crictl pull xyz
curl -k https://my.example.com/api/vx
dig @DNS-server-name Hostname
nc -z -v 10.10.8.8 80
Step 3: Clean Up
When you have finished with the debug pod, don’t forget to delete it from the default namespace.
Enjoy!
Subscribe to my newsletter
Read articles from Fabrice Carrel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by