Tuning Kubelet Garbage Collection & Eviction Thresholds for Devicemapper
Problem
Kubelet does not perform garbage collection with Docker as the underlying Container Runtime using the Device Mapper storage driver.
Environment
Platform9 Managed Kubernetes – All Versions
Kubelet
Docker
Devicemapper
Cause
Due to a an alleged discrepancy in the Kubernetes code, and based on observations made when querying the Kubelet resource metrics, it appears that Kubelet does not properly record the image filesystem usage based on the DM thin-pool; rather, the disk capacity is based on the root disk.
Resolution
Option A (Recommended): Switch to Supported Storage Driver (Overlay2)
Stop the Hostagent and Nodelet daemon services on each worker node.
The node will now show as offline in the Platform9 UI, and you may receive a host-down notification.
Issue a
stopfor the Nodelet phases.
All running pods will be drained and all running containers destroyed. Kubelet will no longer report its status, and the Docker daemon will be brought down also.
Follow Steps #2-#4 from Configuring Docker with the overlay2 Storage Driver.
Start the Hostagent service.
Option B: Tune Kubelet Parameters for Garbage Collection & Eviction Thresholds
Run the
docker infocommand on the worker node and identify theData loop file.
Check the size of the disk/partition on which the data loop file exists and note it down.
Check the size of the data loop file itself and note it down also.
Backup the current worker ConfigMap –
worker-default-kubelet-config.
Edit the
worker-default-kubelet-configConfigMap, and set the following parameters for Garbage Collection (GC) and Eviction Thresholds.
(If necessary, should Kubelet not consume the updated configuration automatically.) Restart the Kubelet service on the worker(s).
Troubleshooting
Scenario: Kubelet Crashed
If Kubelet has crashed with an unexplainable stacktrace or error, it is likely that there was an error in the configuration. Take the following steps to restore the worker(s).
Backup the Kubelet dynamic configuration directory.
Recursively remove the directory.
Restart the Kubelet service.
Additional Information
