<p>I have some pods created by CronJobs that are in <code>Error</code> state and it seems that the CPU / Memory requested by these pods are not released since kubelet is not killing them. It prevents other pods from being scheduled.</p>
<p>Is that the expected behavior ? Should I clean them by hand to get the resources back ?</p>
<p>Thanks.</p>

cyberhippo
<p>Pods in <code>Error</code> you should delete this pod to release resources assigned to it.</p>
<p>However pods in <code>Completed</code> or <code>Failed</code> status are not required to be cleaned up to release resources allocated to them. It can be checked by running simple <code>Job</code> to check memory resources allocated in node.</p>
<p>Memory allocation before job:</p>
<pre><code>Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                   Requests     Limits
  --------                   --------     ------
  cpu                        811m (86%)   1143m (121%)
  memory                     555Mi (19%)  1115Mi (39%)
</code></pre>
<p>Job example:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  creationTimestamp: null
  name: test-job
spec:
  template:
    metadata:
      creationTimestamp: null
    spec:
      containers:
      - command:
        - date
        image: busybox
        name: test-job
        resources:
          requests:
            memory: 200Mi
      restartPolicy: Never 
</code></pre>
<p>Memory after the job deployment:</p>
<pre><code>  Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                   Requests     Limits
  --------                   --------     ------
  cpu                        811m (86%)   1143m (121%)
  memory                     555Mi (19%)  1115Mi (39%)
</code></pre>
