Reputation: 150
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?
Upvotes: 0
Views: 330
Reputation: 687
Judging by PRETTY_NAME
, it's Distroless (https://github.com/GoogleContainerTools/distroless). On their README, you can read
Who uses Distroless?
- Kubernetes, since v1.15
- ...
Which is probably your case.
Upvotes: 0
Reputation: 20196
/etc/os-release
states that the image is based on Distroless
. The SUPPORT_URL given there explains that:
"Distroless" images contain only your application and its runtime dependencies. They do not contain package managers, shells or any other programs you would expect to find in a standard Linux distribution.
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
(requires tar
inside the image);docker cp
on the host to push bash
binary inside the running container.Upvotes: 2