<p>I have a Kubernetes cron job that creates a zip file which takes about 1 hour. After it's completion I want to upload this zip file to an AWS s3 bucket.</p>

<p>How do I tell the cron job to only do the s3 command after the zip is created?</p>

<p>Should the s3 command be within the same cron job?</p>

<p>Currently my YAML looks like this:</p>

<pre><code>kind: CronJob
metadata:
  name: create-zip-upload
spec:
  schedule: "27 5 * * *" # everyday at 05:27 AM
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: mycontainer
            image: 123456789.my.region.amazonaws.com/mycompany/myproject/rest:latest
        args:
        - /usr/bin/python3
        - -m
        - scripts.createzip
</code></pre>

William Ross
<p>Kubernetes doesn't have a concept of a relationship between resources. There isn't an official or clean way to have something occurring in one resource cause an effect on another resource.</p>

<p>Because of this, the best solution is to just put the s3 cmd into the same cronjob.</p>

<p>There's two ways to do this:</p>

<ol>
<li>Add the s3 cmd logic to your existing container.</li>
<li>Create a new container in the same cronjob that watches for the file and then runs the s3 cmd.</li>
</ol>
