<p>I have a CronJob in Kubernetes which is writing logs to console and to a file. Now, I am writing a web application on top this. This application will show all the Jobs and the history of run and logs for each run.</p>

<ol>
<li>Is it possible to get logs from kubernetes for each CronJob run?</li>
<li>Is it possible to have a side car for CronJob like normal containers?</li>
<li>How to get CronJob notification on Job start, Job completion and Job failure?</li>
<li>Does kubernetes generate unique JobId for each run?</li>
<li>Is it possible to have a CronJob with future start time?</li>
</ol>

user1578872
<ol>
<li>Yes, these will be stored in the container logs on the physical node that was responsible for running the job. Additionally, the pod details/state will be retained inside of Kubernetes based on the jobs retention:</li>
</ol>

<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#clean-up-finished-jobs-automatically" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#clean-up-finished-jobs-automatically</a></p>

<ol start="2">
<li>Yes, jobs use the standard <code>spec.Pod</code> specification. Meaning you can have multiple containers running inside of a single pod (ran by the job)</li>
</ol>

<p><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#jobspec-v1-batch" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#jobspec-v1-batch</a>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#podtemplatespec-v1-core" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#podtemplatespec-v1-core</a></p>

<ol start="3">
<li>What do we mean by this? The Kube API is the best way, you can check for the job being triggered and check the status of this job. This typically provides the status of a job:</li>
</ol>

<pre><code>  status:
    completionTime: "2019-10-21T02:13:16Z"
    conditions:
    - lastProbeTime: "2019-10-21T02:13:16Z"
      lastTransitionTime: "2019-10-21T02:13:16Z"
      status: "True"
      type: Complete
    startTime: "2019-10-21T01:00:08Z"
    succeeded: 1
</code></pre>

<ol start="4">
<li>Yes, in the same way pods are given unique identifiers, when a cronjob is triggered a job with a unique identifier is created: </li>
</ol>

<pre><code>user:~$ kubectl get jobs -n elasticsearch
NAME                                                   COMPLETIONS   DURATION   AGE
elasticsearch-elastic-stack-kibana-backup-1571443200   1/1           5s         2d4h
elasticsearch-elastic-stack-kibana-backup-1571529600   1/1           5s         28h
elasticsearch-elastic-stack-kibana-backup-1571616000   1/1           5s         4h58m
</code></pre>
