DEV Community

Cover image for How to limit resources using Quotas & Limit Ranges in OpenShift?
Sagar Jadhav
Sagar Jadhav

Posted on • Updated on • Originally published at developersthought.in

How to limit resources using Quotas & Limit Ranges in OpenShift?

Objective

  • Create project my-project
  • Create Quota & Limit Ranges for project my-project
  • Deploy Node JS Application using S2I
  • Verify allocated Quota & Limits

Step 1: Set up OpenShift environment

Go to Katacoda.com & click on start scenario

Step 2: Create project my-project

oc new-project my-project
Enter fullscreen mode Exit fullscreen mode

Step 3: Create quota

oc create quota project-quota --hard=pods=10
Enter fullscreen mode Exit fullscreen mode

Step 4: Describe quota

oc describe quota project-quota
Enter fullscreen mode Exit fullscreen mode

Step 5: Create limit ranges

vi limits.yaml
Enter fullscreen mode Exit fullscreen mode

Add following limit range

apiVersion: v1
kind: LimitRange
metadata:
    name: project-limits
spec:
    limits:
        -
            type: Container
            max: {cpu: '2'}
            min: {cpu: 100m}
            default: {cpu: 300m}
Enter fullscreen mode Exit fullscreen mode
oc create -f limits.yaml
Enter fullscreen mode Exit fullscreen mode

Step 6: Describe limit ranges

oc describe limits project-limits
Enter fullscreen mode Exit fullscreen mode

Step 7: Describe node

oc describe node localhost | grep -A 4 Allocated
Enter fullscreen mode Exit fullscreen mode

Step 8: Deploy nodejs application using s2i

oc new-app -i nodejs:8 https://github.com/sagar-jadhav/node-hello --name nodejs -l app=demo
Enter fullscreen mode Exit fullscreen mode

Step 9: Describe quota

oc describe quota project-quota
Enter fullscreen mode Exit fullscreen mode

Step 10: Describe limit

oc describe limits project-limits
Enter fullscreen mode Exit fullscreen mode

Step 11: Scale up nodejs application

oc scale dc nodejs --replicas=9
Enter fullscreen mode Exit fullscreen mode

Step 12: Describe quota

oc describe quota project-quota
Enter fullscreen mode Exit fullscreen mode

Step 13: Describe limit

oc describe limits project-limits
Enter fullscreen mode Exit fullscreen mode

Step 14: Scale up nodejs application

oc scale dc nodejs --replicas=15
Enter fullscreen mode Exit fullscreen mode

Step 15: List pods

oc get pods
Enter fullscreen mode Exit fullscreen mode

Step 16: List events

oc get events
Enter fullscreen mode Exit fullscreen mode

Top comments (0)