0
votes

My customer asked me if openshift can provide the same control on memory usage as docker can, for example, docker run can have the following parameters to control memory usage when running a container:

--kernel-memory
--memory
--memory-reservation

While I searched the corresponding part in openshift, I found ResoureQuota and LimitRange should work for that, but what if a pod claims itself will use 100Mi memory by using LimitRange but actually it will consume 500Mi memory instead? the memory can still be used "illegally", seems docker with --memory can control this situation more better.

In openshift, is there any method for controlling real memory usage instead of checking what a pod claimed in LimitRange or using "oc set resources dc hello --requests=memory=256Mi"?

Best regards

Lan

2

2 Answers

1
votes

As far as my experience with Openshift I have not come across the situation where the POD has consumed more memory or CPU for which it has configured. If in case it reaches the threshold, the POD automatically will be killed and restarts.

You can set the POD resource limits in the Deployment config:

resources:
        limits:
          cpu: 750m
          memory: 1024Mi

The resources can be monitored in the metrics section of the respective POD:

enter image description here

Apart from the indiviual POD settings you can define your own overall project settings for each container in the POD.

$ oc get limits
NAME
limits

    $ oc describe limits <NAME>
Name:           <NAME>
Namespace:      <NAME_SPACE>
Type            Resource        Min     Max     Default Request Default Limit   Max Limit/Request Ratio
----            --------        ---     ---     --------------- -------------   -----------------------
Pod             memory          256Mi   32Gi    -               -               -
Pod             cpu             125m    6400m   -               -               -
Container       cpu             125m    6400m   125m            750m            -
Container       memory          256Mi   32Gi    512Mi           1Gi             -

For more information on resource settings refer here.

0
votes

If you only use --requests=memory=256Mi, you set QoS level to "burstable", which means pod can request at least 256Mi memory without upper limit except reaching project quota. If you want to limit pod memory, use --limit=memory=256Mi instead.