<p>I have a GKE cluster where I create jobs through django, it runs my c++ code images and the builds are triggered through github. It was working just fine up until now. However I have recently pushed a new commit to github (It was a really small change, like three-four lines of basic operations) and it built an image as usual. But this time, it said <code>Pod errors: BackoffLimitExceeded, Error with exit code 137</code> when trying to create the job through my simple job, and the job is not completed.</p>
<p>I did some digging into the problem and through runnig <code>kubectl describe POD_NAME</code> I got this output from a failed pod:</p>
<pre><code>Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-api-access-nqgnl:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason               Age    From               Message
  ----     ------               ----   ----               -------
  Normal   Scheduled            7m32s  default-scheduler  Successfully assigned default/xvb8zfzrhhmz-jk9vf to gke-cluster-1-default-pool-ee7e99bb-xzhk
  Normal   Pulling              7m7s   kubelet            Pulling image &quot;gcr.io/videoo3-360019/github.com/videoo-io/videoo-render:latest&quot;
  Normal   Pulled               4m1s   kubelet            Successfully pulled image &quot;gcr.io/videoo3-360019/github.com/videoo-io/videoo-render:latest&quot; in 3m6.343917225s
  Normal   Created              4m1s   kubelet            Created container jobcontainer
  Normal   Started              4m     kubelet            Started container jobcontainer
  Warning  Evicted              3m29s  kubelet            The node was low on resource: ephemeral-storage. Container jobcontainer was using 91144Ki, which exceeds its request of 0.
  Normal   Killing              3m29s  kubelet            Stopping container jobcontainer
  Warning  ExceededGracePeriod  3m19s  kubelet            Container runtime did not kill the pod within specified grace period.
</code></pre>
<p>The error occurs because of this line:</p>
<pre><code>The node was low on resource: ephemeral-storage. Container jobcontainer was using 91144Ki, which exceeds its request of 0.
</code></pre>
<p>I do not have a yaml file where I set my pod informations, instead I make a django call handle configuration which looks like this:</p>
<pre class="lang-py prettyprint-override"><code>def kube_create_job_object(name, container_image, namespace=&quot;default&quot;, container_name=&quot;jobcontainer&quot;, env_vars={}):
    # Body is the object Body
    body = client.V1Job(api_version=&quot;batch/v1&quot;, kind=&quot;Job&quot;)
    # Body needs Metadata
    # Attention: Each JOB must have a different name!
    body.metadata = client.V1ObjectMeta(namespace=namespace, name=name)
    # And a Status
    body.status = client.V1JobStatus()
     # Now we start with the Template...
    template = client.V1PodTemplate()
    template.template = client.V1PodTemplateSpec()
    # Passing Arguments in Env:
    env_list = []
    for env_name, env_value in env_vars.items():
        env_list.append( client.V1EnvVar(name=env_name, value=env_value) )

    print(env_list)
    security = client.V1SecurityContext(privileged=True, allow_privilege_escalation=True, capabilities= client.V1Capabilities(add=[&quot;CAP_SYS_ADMIN&quot;]))
    container = client.V1Container(name=container_name, image=container_image, env=env_list, stdin=True, security_context=security)
    template.template.spec = client.V1PodSpec(containers=[container], restart_policy='Never')
    body.spec = client.V1JobSpec(backoff_limit=0, ttl_seconds_after_finished=600, template=template.template)
    return body



def kube_create_job(manifest, output_uuid, output_signed_url, webhook_url, valgrind, sleep, isaudioonly):
    credentials, project = google.auth.default(
        scopes=['https://www.googleapis.com/auth/cloud-platform', ])
    credentials.refresh(google.auth.transport.requests.Request())
    cluster_manager = ClusterManagerClient(credentials=credentials)
    cluster = cluster_manager.get_cluster(name=f&quot;path/to/cluster&quot;)

    with NamedTemporaryFile(delete=False) as ca_cert:
        ca_cert.write(base64.b64decode(cluster.master_auth.cluster_ca_certificate))

    config = client.Configuration()
    config.host = f'https://{cluster.endpoint}:443'
    config.verify_ssl = True
    config.api_key = {&quot;authorization&quot;: &quot;Bearer &quot; + credentials.token}
    config.username = credentials._service_account_email
    config.ssl_ca_cert = ca_cert.name
    client.Configuration.set_default(config)

    # Setup K8 configs
    api_instance = kubernetes.client.BatchV1Api(kubernetes.client.ApiClient(config))

    container_image = get_first_success_build_from_list_builds(client)
    name = id_generator()
    body = kube_create_job_object(name, container_image,
                                  env_vars={
                                            &quot;PROJECT&quot;           : json.dumps(manifest),
                                            &quot;BUCKET&quot;            : settings.GS_BUCKET_NAME,
                                           })
    try:
        api_response = api_instance.create_namespaced_job(&quot;default&quot;, body, pretty=True)
        print(api_response)
    except ApiException as e:
        print(&quot;Exception when calling BatchV1Api-&gt;create_namespaced_job: %s\n&quot; % e)
    return body
</code></pre>
<p>What causes this and how can I fix it? Am I supposed to set resource/limit varibles to a value and if so how can I do that inside my django job call?</p>

Turgut
<p>It looks like you are running out of storage on the actual node itself.  Since your job spec does not have a request for ephemeral storage, it is being scheduled on any node and in this case it appears like that particular node does not have enough storage available.</p>
<p>I'm not a Python expert, but looks like you should be able to do something like:</p>
<pre><code>storage_size = SOME_VALUE
requests = {'ephemeral-storage': storage_size}
resources = client.V1ResourceRequirements(requests=requests)
container = client.V1Container(name=container_name, image=container_image, env=env_list, stdin=True, security_context=security, resources=resources)
</code></pre>
