Requests and Limits

Requests and Limits


Relevant Documentation

Lesson Reference

Create a pod with resource requests that exceed available node resources.
  1. Create a YAML file named big-request-pod.yml and open it for editing:
vi big-request-pod.yml
  1. Add the following content to the file:
apiVersion: v1 kind: Pod metadata: name: big-request-pod spec: containers: - name: busybox image: busybox command: ['sh', '-c', 'while true; do sleep 3600; done'] resources: requests: cpu: "10000m" memory: "128Mi"
  1. Save and close the file.
  1. Create the pod using the YAML file:
kubectl create -f big-request-pod.yml
  1. Check the status of the pod. It should remain in the Pending state since no worker nodes have enough resources to meet the request:
kubectl get pod big-request-pod
  • Create a pod with resource requests and limits.
  1. Create a YAML file named resource-pod.yml and open it for editing:
vi resource-pod.yml
  1. Add the following content to the file:
apiVersion: v1 kind: Pod metadata: name: resource-pod spec: containers: - name: busybox image: busybox command: ['sh', '-c', 'while true; do sleep 3600; done'] resources: requests: cpu: "250m" memory: "128Mi" limits: cpu: "500m" memory: "256Mi"
  1. Save and close the file.
  1. Create the pod using the YAML file:
kubectl create -f resource-pod.yml
  1. Check the status of the pod:
kubectl get pods