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.
Nope, Kubernetes no more reserves memory or CPU once Pods are marked completed.
Providing you this example using a local minikube
instance.
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: {}
# 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%)
# 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%)
# 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%)