一个完整的kubernetes pod是否仍保留所需的资源?

caa*_*os0 1 kubernetes

如果我有一个CronJob的有requests.memory,让我们说的100Mi,当容器完成和进入Completed状态,确实它仍然“保留”是的内存量,或者所请求的资源释放出来?

这两个职位的文档波德生命周期文档不指定在舱体后会发生什么Completed阶段。

pro*_*ion 5

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: {}
Run Code Online (Sandbox Code Playgroud)

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%)
Run Code Online (Sandbox Code Playgroud)

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%)
Run Code Online (Sandbox Code Playgroud)

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%)
Run Code Online (Sandbox Code Playgroud)

  • 处于失败阶段的 Pod 似乎也没有保留资源。 (2认同)