Limiting microk8s maximum memory usage Limiting microk8s maximum memory usage kubernetes kubernetes

Limiting microk8s maximum memory usage


Since microk8s running on the host machine, then all resources of the host are allocated for it. That is why if you want to keep your cluster resources in borders, you have to manage them in one of the ways below:

  1. Setup LimitRange policy for pods in a namespace.

A LimitRange 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.
  1. Use Resource Quotas per namespace.

A resource quota, defined by a ResourceQuota object, providesconstraints that limit aggregate resource consumption per namespace.It can limit the quantity of objects that can be created in anamespace by type, as well as the total amount of compute resourcesthat may be consumed by resources in that namespace.

  1. Assign necessary requests and limits for each pod.

When you specify the resource request for Containers in a Pod, thescheduler uses this information to decide which node to place the Podon. When you specify a resource limit for a Container, the kubeletenforces those limits so that the running container is not allowed touse more of that resource than the limit you set. The kubelet alsoreserves at least the request amount of that system resourcespecifically for that container to use.