<p>I am trying to schedule Python Script through Kubernetes CronJob but for some reason I am not able to understand how can I do it. I am able to run simple script like <code>echo Hello World</code> but that's not what I want</p>

<p>I tried using this specification:</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: test
spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: "Forbid"
  failedJobsHistoryLimit: 10
  startingDeadlineSeconds: 600 # 10 min
  jobTemplate:
    spec:
      backoffLimit: 0
      activeDeadlineSeconds: 3300 # 55min
      template:
        spec:
          containers:
            - name: hello
              image: python:3.6-slim
              command: ["python"]
              args: ["./main.py"]
          restartPolicy: Never
</code></pre>

<p>But then I am not able to run it because main.py is not found, I understand that relative path is not supported so I hardcoded the path but then I am not able to find my home directory, I tried doing <code>ls /home/</code> and over there my folder name is not visible so I am not able to access my project repository.</p>

<p>Initially I was planning to run bash script which can do:</p>

<ol>
<li>Install requirements by <code>pip install requirements.txt</code></li>
<li>Then run Python script</li>
</ol>

<p>But I am not sure how can I do this with kubernetes, It is so confusing to me</p>

<p>In short I want to be able to run k8s CronJob which can run Python script by first installing requirements and then running it</p>

<p>where is the startup script ./main.py located? is it present in the image.
you need to build new image using python:3.6-slim as base image and add your python script to PATH. then you would be able to run it from k8s CronJob</p>
