Kubernetes Pod Resource Limiting Guide

Set Resource Limits in Kubernetes Pods

Set Resource Limits in Kubernetes Pods

How to Define Resource Restrictions for Kubernetes Pods

Steps

  • Create a pod named httpd-pod with a container named httpd-container.

  • Use the httpd image with the latest tag (httpd:latest).

  • Set resource requests:

    • Memory: 15Mi

    • CPU: 100m

  • Set resource limits:

    • Memory: 20Mi

    • CPU: 100m

Tasks

  1. Create a manifest yaml file, httpd-pod.yaml

     apiVersion: v1
     kind: Pod
     metadata:
       name: httpd-pod
     spec:
       containers:
       - name: httpd-container
         image: httpd:latest
         resources:
           requests:
             memory: "15Mi"
             cpu: "100m"
           limits:
             memory: "20Mi"
             cpu: "100m"

    As I prefer EOF,

  2. Apply the manifest file

     kubectl apply -f httpd-pod.yaml
  3. pod/httpd-pod created. Now, Verify the Pod.

     kubectl get pods
  4. Then, check the resources on given pod

     kubectl describe pod httpd-pod

#k8s #kubernetes #devops #pods #limitation #happylearning