<h2>problem description:</h2>
<pre><code>❯ kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.24.2
Kustomize Version: v4.5.4
Server Version: v1.23.4
</code></pre>
<p>The cri is docker</p>
<pre><code>docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:02:57 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:03 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
</code></pre>
<p>I tried to use temporal pod to debug coredns pod with below commands but failed</p>
<pre><code>❯ kubectl debug -it ephemeral-demo --image=busybox:1.28 --target=coredns-64897985d-2xgd6
Targeting container &quot;coredns-64897985d-2xgd6&quot;. If you don't see processes from this container it may be because the container runtime doesn't support this feature.
Error from server (NotFound): pods &quot;ephemeral-demo&quot; not found
</code></pre>
<h3>ps</h3>
<p>I found the feature of podShareProcessNamespace is enabled by default after 1.17
And I can also finish the job described in the <a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container</a> with below details</p>
<pre><code>❯ kubectl debug -it ephemeral-demo --image=busybox:1.28 --target=ephemeral-demo

Targeting container &quot;ephemeral-demo&quot;. If you don't see processes from this container it may be because the container runtime doesn't support this feature.
Defaulting debug container name to debugger-mqth2.
If you don't see a command prompt, try pressing enter.
/ #
</code></pre>

xiaojueguan
<p>Actually, the feature is functional. It is misunderstand the meaning of the doc <a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container</a>.</p>
<p>We can use below two steps to use the feature of using ephemeral container to debug.</p>
<ol>
<li>patch your deployment with below command</li>
</ol>
<pre><code>kubectl patch deployment coredns --patch '
spec:
  template:
    spec:
      shareProcessNamespace: true'
</code></pre>
<ol start="2">
<li>start a ephemeral container to use debug tools to debug</li>
</ol>
<pre><code>kubectl debug -it -c debug coredns-7f96c4ccc7-pfhxj --image busybox:latest
</code></pre>
<hr />
<p>But the error promotion(If you don't see processes from this container it may be because the container runtime doesn't support this feature.) is some kind of confusing.</p>
<p>And the description that The --target parameter targets the process namespace of another container in the doc <a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container</a> can also be a little confusing.</p>
<hr />
<p>By reading this i may know what the vaule that --target can be assigned which can be the name of the container in the pod spec.</p>
