<p>I have some services running on a namespace in kubernetes. I have created a job to run my api tests pointing to these services and when this job is finished(succeeded), I would like to be able to copy the json reports to my machine. I tried to use <code>kubectl cp</code> but this just works when the pod is still running. </p>

<p>Does anyone know how can I copy these reports after the job is completed ? I tried to create a deployment so I would be able to copy these reports, but then there is no <code>restartpolicy</code> for deployments and the tests were restarting everytime, which made me lost the reports before I was able to copy them. Also tried to just create a pod with the <code>restartpolicy: NEVER</code> but I had the same problem as the job.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: api-tests
  namespace: tests
spec:
    restartPolicy: Never
    containers:
    - name: api-tests
      image: api-tests:latest
      args: 
          - run
          - https://www.getpostman.com/collections/test23423423
          - -e
          - /etc/newman/envs/kubernetes.postman_environment.json 
          - -d
          - /etc/newman/data/tests.csv
          - --reporters
          - cli,html,json
          - --reporter-json-export
          - /etc/newman/target/api_tests.json
          - --reporter-html-export
          - /etc/newman/target/api_tests.html
          - --reporter-cli-no-failures
</code></pre>

<p>This is the <code>job.yaml</code> that I have at the moment.</p>

<p>Any ideas are more than welcome.</p>

rafazzevedo
<p>I think you can push your reports to some system like git server, or you can place the reports to shared storage like nfs using <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistent-volumes" rel="nofollow noreferrer">persistentvolume(PV)</a>. Your jobs are going to run a specific node host then you can also review the <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">hostPath</a> to share the reports with host server from pods.</p>

<p>I hope it helpful to you.</p>
