# Not able to get shell of the running containers in kube-system namespace

**URL:** <https://discuss.kubernetes.io/t/not-able-to-get-shell-of-the-running-containers-in-kube-system-namespace/16334>\
**Category:** General Discussions\
**Created:** [June 11, 2021, 11:44pm UTC](https://discuss.kubernetes.io/t/not-able-to-get-shell-of-the-running-containers-in-kube-system-namespace/16334 "2021-06-11T23:44:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![inbox.amitraj](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/inbox.amitraj/32/7646_2.png) [@inbox.amitraj](https://discuss.kubernetes.io/u/inbox.amitraj)\
**Post date:** [June 11, 2021, 11:44pm UTC](https://discuss.kubernetes.io/t/not-able-to-get-shell-of-the-running-containers-in-kube-system-namespace/16334/1 "2021-06-11T23:44:01Z")

</div>

Hi All,

I am trying to get shell of a control plane container e.g. I would like to get to the shell of the Etcd container running in tube-system namespace.

$ k exec -it etcd-master01 – /bin/bash -n kube-system  
Error from server (NotFound): pods “etcd-master01” not found  
$

$ k get pods -n kube-system  
NAME READY STATUS RESTARTS AGE  
coredns-558bd4d5db-269lt 1/1 Running 8 30d  
coredns-558bd4d5db-967d8 1/1 Running 8 30d  
etcd-master01 1/1 Running 8 30d  
kube-apiserver-master01 1/1 Running 16 16d  
kube-controller-manager-master01 1/1 Running 42 30d  
kube-proxy-q8mkb 1/1 Running 8 30d  
kube-proxy-x6trg 1/1 Running 9 29d  
kube-proxy-xxph9 1/1 Running 8 29d  
kube-scheduler-master01 1/1 Running 37 30d  
weave-net-rh2gb 2/2 Running 17 29d  
weave-net-s2cg9 2/2 Running 19 29d  
weave-net-wksk2 2/2 Running 19 30d  
$

could you please help.

Thank you

---

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [June 12, 2021, 4:04am UTC](https://discuss.kubernetes.io/t/not-able-to-get-shell-of-the-running-containers-in-kube-system-namespace/16334/2 "2021-06-12T04:04:10Z")

</div>

[Namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/), they’re very important for organizing your workloads.

```nohighlight
$ kubectl -n kube-system exec -it etcd-master01 -- /bin/bash

```

Edit: I copy/pasted a `–` instead of `--`. Fixed, because necessary.  
Edit 2: Copy paste just isn’t my friend.

---

<div class="post-metadata">

**Author:** ![inbox.amitraj](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/inbox.amitraj/32/7646_2.png) [@inbox.amitraj](https://discuss.kubernetes.io/u/inbox.amitraj)\
**Post date:** [June 12, 2021, 1:48pm UTC](https://discuss.kubernetes.io/t/not-able-to-get-shell-of-the-running-containers-in-kube-system-namespace/16334/3 "2021-06-12T13:48:05Z")

</div>

Thank you @protosam, I also realised that bash was not the correct shell

vagrant@master01:~$ kubectl -n kube-system exec -it etcd-master01 – /bin/sh  
sh-5.0#

Thank you

---

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [June 12, 2021, 4:25pm UTC](https://discuss.kubernetes.io/t/not-able-to-get-shell-of-the-running-containers-in-kube-system-namespace/16334/4 "2021-06-12T16:25:59Z")

</div>

Yeah, it’s pretty common for bash to not be available. Some containers don’t seem to offer you any way to access them too. Like the apiserver doesn’t have a shell available as far as I can tell.

Edit: I found out why this is. Applications written in go don’t really need much in the way of OS. Using multi-stage builds, you can build a Go application and just copy it to an empty container pretty much.

Docker provides `FROM scratch` which I can only assume is a keyword to facilitate such a minimalistic container builds or building a new OS container.

Google also has [ko](https://github.com/google/ko) for building Go based images.
