Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a completed kubernetes pod still reserves the required resources?

Tags:

kubernetes

If I have a CronJob the has requests.memory of, let's say, 100Mi, when the pod finishes and enter on Completed state, does it still "reserves" that amount of memory, or are the requested resources freed up?

Both Jobs docs and Pod Lifecycle docs don't specify what happens after the pods in on Completed phase.

like image 391
caarlos0 Avatar asked Aug 28 '19 17:08

caarlos0


People also ask

Do Kubernetes pods share resources?

Pods are the smallest, most basic deployable objects in Kubernetes. A Pod represents a single instance of a running process in your cluster. Pods contain one or more containers, such as Docker containers. When a Pod runs multiple containers, the containers are managed as a single entity and share the Pod's resources.

How do you configure a Kubernetes job so that pods are retained after completion?

How do you configure a Kubernetes Job so that Pods are retained after completion? a) Configure the backofflimit parameter with a non-zero value. b) Set a startingDeadlineSeconds value high enough to allow you to access the logs. c) Configure the cascade flag for the Job with a value of false.


1 Answers

Nope, Kubernetes no more reserves memory or CPU once Pods are marked completed.

Providing you this example using a local minikube instance.

the Job manifest

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
status: {}

the Node describe output

# kubectl describe node|grep -i mem -C 5
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests     Limits
  --------           --------     ------
  cpu                755m (37%)   0 (0%)
  memory             190Mi (10%)  340Mi (19%)

Applying the job and then describing the node

# kubectl create -f job.yaml && kubectl describe node | grep -i mem -C 5
job.batch/test-job created
(...)
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests     Limits
  --------           --------     ------
  cpu                755m (37%)   0 (0%)
  memory             390Mi (22%)  340Mi (19%)

describe again the Node after the Job completion

# kubectl describe node | grep -i mem -C 5
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests     Limits
  --------           --------     ------
  cpu                755m (37%)   0 (0%)
  memory             190Mi (10%)  340Mi (19%)
  ephemeral-storage  0 (0%)       0 (0%)
like image 100
prometherion Avatar answered Oct 08 '22 05:10

prometherion