I logged into Kubernetes etcd pod
kubectl exec -it -n kube-system etcd-master -- /bin/sh
I cannot figure out what OS is it.
ls does not work
sh-5.0# ls
sh: ls: command not found
cat does not work
sh-5.0# cat /etc/os-release
sh: cat: command not found
apt,yum not recognized
sh-5.0# apt
sh: apt: command not found
sh-5.0# yum
sh: yum: command not found
I can only cd and list files via pattern expansion
sh-5.0# cd /etc
sh-5.0# echo *
debian_version default dpkg group host.conf hostname hosts issue issue.net kubernetes network nsswitch.conf os-release passwd profile.d protocols resolv.conf rpc services skel ssl update-motd.d
sh-5.0# echo `<os-release`
PRETTY_NAME="Distroless" NAME="Debian GNU/Linux" ID="debian" VERSION_ID="9" VERSION="Debian GNU/Linux 9 (stretch)" HOME_URL="https://github.com/GoogleContainerTools/distroless" SUPPORT_URL="https://github.com/GoogleContainerTools/distroless/blob/master/README.md" BUG_REPORT_URL="https://github.com/GoogleContainerTools/distroless/issues/new"
What operating system is it? How to install bash here?
2
Answers
/etc/os-release
states that the image is based onDistroless
. The SUPPORT_URL given there explains that:This is one of the best practices with containers to leave only what is absolutely necessary inside. You may encounter many such images and some even won’t have
sh
in it. Moreover, root filesystem can be read only and/or the container might not have enough privileges to install things.With all this in mind, it may be so that you will not be able to bring
bash
or anything else inside. Depending on your actual goal, you may:kubectl cp
(requirestar
inside the image);docker cp
on the host to pushbash
binary inside the running container.Judging by
PRETTY_NAME
, it’s Distroless (https://github.com/GoogleContainerTools/distroless). On their README, you can readWhich is probably your case.