<p>I have a test process which produces a file as an output.</p>

<p>I want to start this test process during a build, run it to completion, then collect the file that it produces and copy it back into the build context.</p>

<p>What is the correct way to do this in Kubernetes/Helm?</p>

<p>The build process has access to <code>kubectl</code> and <code>helm</code> CLI tools.</p>

<p>I have a requirement not to use <code>kubectl exec</code>, because the cluster settings do not allow it.</p>

<p><strong>Some details:</strong></p>

<p>I was able to configure a one-off process using a <code>Pod</code>.</p>

<p>I set up the process to store the output file in a volume mount, which is mounted to an <code>emptyDir</code> volume.</p>

<p>I cannot figure out how to get the output file.</p>

<p>I tried <code>kubectl cp</code>, but I can't get it to work (no such file or directory).</p>

<p>I can't figure out how to inspect the contents of a stopped container.</p>

<p>I can't figure out how to see what's in the volume.</p>

<p><code>kubectl logs</code> shows that the test process ran successfully. The file is generated within the container and stored at the expected location.</p>

<p><strong>Quick update:</strong></p>

<p>In my local minikube environment, I was able to set up a persistent volume and copy the output file back to the host file system. I will try it next in Jenkins environment.</p>

<p>Here is the output from <code>kubectl cp</code> on my local (boot2docker) environment:</p>

<pre><code>$ kubectl cp my-pod:/home/node/output . -c mycontainer
error: home/node/output no such file or directory
</code></pre>

<p><code>/home/node/output</code> is the volumeMount path within the container.</p>

RMorrisey
<blockquote>
  <p>I have a requirement not to use kubectl exec, because the cluster settings do not allow it.</p>
</blockquote>

<p>Without the <code>kubectl exec</code> command, I can suggest to do it that way:</p>

<ol>
<li>Run your test as a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" rel="nofollow noreferrer">Job</a> inside a cluster.</li>
<li>Use shared volume like NFS or SMB to store your file.</li>
<li>Get files from the shared volume, which you can mount to your build system.</li>
</ol>

<p>Also, many build systems have an Artifacts storage, and it can be the best option to store test results.</p>
