02 - Resource Requirements and Limits

參考資源

[K8s] Manage Memory, CPU, and API Resources

[K8s] Limit Ranges

[K8s] Configure Default CPU Requests and Limits for a Namespace

[K8s] Configure Default Memory Requests and Limits for a Namespace

[Udemy] 第66、67堂課:Resource Requirements and Limits


Q: Another pod called `elephant` has been deployed in the default namespace. It fails to get to a running state. Inspect this pod and identify the Reason why it is not running.

$ kubectl describe pod elephant                          

The reason for the pod not running is OOMKilled.
This means that the pod ran out of memory.
 


Inspect the status of POD.

$ watch kubectl get pods                             

Note: - Make use of the `CTRL + C` key to exit from the process.


Q: The `elephant` pod runs a process that consumes 15Mi of memory. Increase the limit of the `elephant` pod to 20Mi.

Note: Delete and recreate the pod if required. Do not modify anything other than the required fields.

  • Pod Name: elephant
  • Image Name: polinux/stress
  • Memory Limit: 20Mi

注意:你 無法直接修改 環境變數 (env)、ServiceAccount、資源限制 (resource limits) 等內容。


【方法一】匯出 YAML,修改後重建

$ kubectl get pod elephant -o yaml > elephant.yaml               
$ kubectl replace -f elephant.yaml --force                           

This command (kubectl replace -f elephant.yaml --force) will delete the existing one first and recreate a new one from the YAML file.

edit the file such as memory limit is set to 20Mi


留言