A limit range, defined by a LimitRange object, provides constraints that can:
- Enforce minimum and maximum compute resources usage per Pod or Container in a namespace.
- Enforce minimum and maximum storage request per PersistentVolumeClaim in a namespace.
- Enforce a ratio between request and limit for a resource in a namespace.
- Set default request/limit for compute resources in a namespace and automatically inject them to Containers at runtime.
bash-4.2$ kubectl describe limitranges -n ovi
Name: ovi-limitrange
Namespace: ovi
Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio
—- ——– — — ————— ————- ————————————————————
Container memory 64Mi 32Gi 64Mi 512Mi 10
Container cpu 100m 16 100m 500m 8
Edit limit range
bash-4.2$ kubectl edit limitranges -n ovi
# Please edit the object below. Lines beginning with a ‘#’ will be ignored,
2 # and an empty file will abort the edit. If an error occurs while saving this file will be
3 # reopened with the relevant failures.
4 #
5 apiVersion: v1
6 kind: LimitRange
7 metadata:
8 annotations:
9 kubectl.kubernetes.io/last-applied-configuration: |
10 {“apiVersion”:”v1″,”kind”:”LimitRange”,”metadata”:{“annotations”:{},”name”:”ovi-limitrange”,”namespace”:”ovi”},”spec”:{“limits”:[{“default”:{“cpu”:”500m”,”m emory”:”512Mi”},”defaultRequest”:{“cpu”:”100m”,”memory”:”64Mi”},”max”:{“cpu”:”16″,”memory”:”32Gi”},”maxLimitRequestRatio”:{“cpu”:”8″,”memory”:”10″},”min”:{“cpu”:”10 0m”,”memory”:”64Mi”},”type”:”Container”}]}}
11 creationTimestamp: 2019-02-13T15:54:44Z
12 name: ovi-limitrange
13 namespace: ovi
14 resourceVersion: “127366586”
15 selfLink: /api/v1/namespaces/te20/limitranges/ovi-limitrange
16 uid: ae91e929-2fa7-11e9-9dd5-0242ac110005
17 spec:
18 limits:
19 – default:
20 cpu: 500m
21 memory: 512Mi
22 defaultRequest:
23 cpu: 100m
24 memory: 64Mi
25 max:
26 cpu: “16”
27 memory: 32Gi
28 maxLimitRequestRatio:
29 cpu: “8”
30 memory: “10”
31 min:
32 cpu: 100m
33 memory: 64Mi
34 type: Container