<p>I want to delete a specific file from a cronJob to the following container, the problem is that when I run exec I got error, how can I exec to distroless container (k8s v1.22.5) and delte the file from a cronJob, which option do we have?</p>
<p>this is the deployment</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: distro
  labels:
    app: distro
spec:
  replicas: 1
  selector:
    matchLabels:
      app: distro
  template:
    metadata:
      labels:
        app: distro
    spec:
      containers:
        - name: edistro
          image: timberio/vector:0.21.X-distroless-libc
          ports:
            - containerPort: 80
</code></pre>
<p>what I tried is</p>
<pre class="lang-sh prettyprint-override"><code>kubectl exec -i -t -n apits aor-agent-zz -c tor &quot;--&quot; sh -c &quot;clear; (bash || ash || sh)&quot;
</code></pre>
<p>The error is:</p>
<pre class="lang-sh prettyprint-override"><code>error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec
</code></pre>
<p>I tried it out like following</p>
<pre class="lang-sh prettyprint-override"><code>kubectl debug -it distro-d49b456cf-t85cm --image=ubuntu --target=edistro  --share-processes -n default
</code></pre>
<p><strong>And got error:</strong></p>
<pre><code>Targeting container &quot;edistro&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-fvfxs. error: ephemeral containers are disabled for this cluster (error from server: &quot;the server could not find the requested resource&quot;).
</code></pre>
<p>As I guess (not sure) that our the container runtime doesnt support it which option do we have?</p>
<p><strong>The answer below</strong> doesn't solve the issue, I need a way to access from <strong>outside the distroless pod</strong> and delete specific file there, how can I do this?</p>

PJEM
<p>The point of using <code>distro-less</code> is to have a minimal amount of tools/software packaged in the image. This means the removal of unnecessary tools like <code>shell</code> from the image.</p>
<p>You may work around using, however it may depend on your objective:</p>
<pre><code>kubectl debug -it &lt;POD_TO_DEBUG&gt; --image=&lt;helper-image&gt; --target=&lt;CONTAINER_TO_DEBUG&gt; --share-processes
</code></pre>
<p>Eg:</p>
<pre><code>kubectl debug -it distro-less-pod   --image=ubuntu --target=edistro  --share-processes
</code></pre>
