Pod CPU / Memory requests in error state are not released

989 Views Asked by At

I have some pods created by CronJobs that are in Error 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.

Is that the expected behavior ? Should I clean them by hand to get the resources back ?

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

Pods in Error you should delete this pod to release resources assigned to it.

However pods in Completed or Failed status are not required to be cleaned up to release resources allocated to them. It can be checked by running simple Job to check memory resources allocated in node.

Memory allocation before job:

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%)

Job example:

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 

Memory after the job deployment:

  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%)