<p>I have a Kubernetes cron job that gets an OOMKilled (Out of Memory) message when running. This specific cron job runs once a day. The node itself has 4 GB of RAM.</p>

<p>Found somewhere that said the default for a cron job is 100 MB? Where can I view or change the default for Kubernetes cron jobs?</p>

William Ross
<p>You can just add resources and limits to that job so you can prevent it from being OOM killed. One thing to note is how resources and limits work. I have explained some scenarios in this <a href="https://stackoverflow.com/questions/54184886/what-is-the-use-case-of-setting-memory-request-less-than-limit-in-k8s/54203128#54203128">answer</a> on Stack. It is worthy to check the official <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container" rel="noreferrer">documentation</a> to avoid common mistakes and also CPU and Memory resources/limits work a little bit different. </p>

<p>About the default values of resources and limits it depends on where is your cluster. For example in my kubeadm I do not have any resources or limits by default in <code>default</code> namespace:</p>

<pre><code>kubectl describe ns default
Name:         default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;
Status:       Active

No resource quota.

No resource limits.
</code></pre>

<p>And this is for GKE:</p>

<p><a href="https://i.stack.imgur.com/kNdMN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kNdMN.png" alt="GKE"></a></p>

<p>So your choice is to set up Requests and Limits for your namespace or just add it into the Job spec, like in this example:</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: testing-hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hi-there
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo "Hello, World!"
            resources:
              requests:
                cpu: "100Mi"
              limits:
                cpu: "100Mi"
          restartPolicy: OnFailure
</code></pre>

<p>Also usually you would just set resources and limits per namespace as it is described <a href="https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/#create-a-namespace" rel="noreferrer">here</a>.</p>
