How to set limit for kubelet of kubernetes?

11/1/2019

I am using kubernetes cluster with 1 master node and 2 worker with 4 core cpu and 256mb ram. I wanted to know how much cpu and ram is needed for kubelet.

Is there any way to set limit (cpu, memory) for kubelet?. I searched for documentation but i found only worker node requirements.

--
containers
docker
kubelet
kubernetes
pod

1 Answer

11/1/2019

I think you should understand what kubelet does. This can be found in kubelet documentation.

The kubelet is the primary “node agent” that runs on each node. It can register the node with the apiserver using one of: the hostname; a flag to override the hostname; or specific logic for a cloud provider.

The kubelet works in terms of a PodSpec. A PodSpec is a YAML or JSON object that describes a pod. The kubelet takes a set of PodSpecs that are provided through various mechanisms (primarily through the apiserver) and ensures that the containers described in those PodSpecs are running and healthy. The kubelet doesn’t manage containers which were not created by Kubernetes.

Other than from an PodSpec from the apiserver, there are three ways that a container manifest can be provided to the Kubelet.

File: Path passed as a flag on the command line. Files under this path will be monitored periodically for updates. The monitoring period is 20s by default and is configurable via a flag.

HTTP endpoint: HTTP endpoint passed as a parameter on the command line. This endpoint is checked every 20 seconds (also configurable with a flag).

HTTP server: The kubelet can also listen for HTTP and respond to a simple API (underspec’d currently) to submit a new manifest.

There is several flags that you could use with kubelet, but they mostly are DEPRECATED and parameter should be set via config file specified by Kubelet's --config flag. This is explain on Set Kubelet parameters via a config file.

The flags that might be interesting for you are:

--application-metrics-count-limit int

Max number of application metrics to store (per container) (default 100) (DEPRECATED)

--cpu-cfs-quota

Enable CPU CFS quota enforcement for containers that specify CPU limits (default true) (DEPRECATED)

--event-qps int32

If > 0, limit event creations per second to this value. If 0, unlimited. (default 5) (DEPRECATED)

--event-storage-age-limit string

Max length of time for which to store events (per type). Value is a comma separated list of key values, where the keys are event types (e.g.: creation, oom) or "default" and the value is a duration. Default is applied to all non-specified event types (default "default=0") (DEPRECATED)

--event-storage-event-limit string

Max number of events to store (per type). Value is a comma separated list of key values, where the keys are event types (e.g.: creation, oom) or "default" and the value is an integer. Default is applied to all non-specified event types (default "default=0") (DEPRECATED)

--log-file-max-size uint

Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)

--pods-per-core int32

Number of Pods per core that can run on this Kubelet. The total number of Pods on this Kubelet cannot exceed max-pods, so max-pods will be used if this calculation results in a larger number of Pods allowed on the Kubelet. A value of 0 disables this limit. (DEPRECATED)

--registry-qps int32

If > 0, limit registry pull QPS to this value. If 0, unlimited. (default 5) (DEPRECATED)

-- Crou
Source: StackOverflow