Closed max-rocket-internet closed 4 months ago
There is a way (and TIL, thanks for sharing kubectl debug
!). You can do this:
kubectl debug node/<node> -it --image=<image>:<tag> --profile=sysadmin
And in the newly created pod:
chroot /host apiclient exec admin bash
And you should be at the admin container now (provided that you have the admin
container enabled). But, keep in mind the high privilege you are giving to the pod, make sure you its gone after you are done debugging!
But obviously chroot /host does not work.
It does! But by default it will try to execute a shell, which we don't have in Bottlerocket. So, you can still run commands like chroot /host journalctl
or chroot /host ctr -n k8s.io tasks ls
to debug some things, but you will be limited to what the host provides. That's why I posted how to enter the admin container from the debug pod, so that you can install tools if you need them.
OK interesting @arnaldo2792! But where do you get this profile
? I'm using versionv1.28.3
and it's not there:
~ kubectl debug node/ip-10-10-19-38.eu-west-1.compute.internal --profile=sysadmin -it --image=ubuntu
error: unknown profile: sysadmin
The profiles are version-dependent. I used kubelet
v1.30.X, and it allowed me to use the sysadmin
profile:
~ ❯ kubectl version
Client Version: v1.30.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.9-eks-036c24b
@arnaldo2792 can I open a PR to update the FAQ? If so, where? It would be quite useful to share this I think.
Of course! I think this will be the best place to document this:
https://github.com/bottlerocket-os/bottlerocket-project-website
Under FAQ items
kubectl
added some great options under thedebug
command and even the main Kubernetes docs have a page about debugging nodes with it here. You can see some technical details here about how it works.But obviously
chroot /host
does not work.Is there some way to make this work? To access to
enter-admin-container
fromkubectl debug node
? It would be great because it would allow host debug without leavingkubectl
🙏