DEV Community

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

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

2

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

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay