<p>I need to execute a diagnostic program written for my application. The application is running/deployed in a Kubernetes pod. I want to copy a diagnostic executable jar file inside the Kubernetes pod and execute it without stopping the pod. How can this be achieved ? Is there a specific way to run the executable jar using the Kubernetes pod environment in place ?</p>

<p>You can try the <code>kubectl cp</code> command:</p>
<p>From the <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" rel="noreferrer">docs</a>:</p>
<blockquote>
<p>Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in
the default namespace</p>
</blockquote>
<pre><code>kubectl cp /tmp/foo_dir &lt;some-pod&gt;:/tmp/bar_dir
</code></pre>
<blockquote>
<p>Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific
container</p>
</blockquote>
<pre><code>kubectl cp /tmp/foo &lt;some-pod&gt;:/tmp/bar -c &lt;specific-container&gt;
</code></pre>
<blockquote>
<p>Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace</p>
</blockquote>
<pre><code>kubectl cp /tmp/foo &lt;some-namespace&gt;/&lt;some-pod&gt;:/tmp/bar
</code></pre>
<blockquote>
<p>Copy /tmp/foo from a remote pod to /tmp/bar locally</p>
</blockquote>
<pre><code>kubectl cp &lt;some-namespace&gt;/&lt;some-pod&gt;:/tmp/foo /tmp/bar
</code></pre>
<p>Once the executable is added inside the container, you can <code>exec</code> into the pod and execute the file manually.</p>
