How To Enable fail-on-swap=false Option as a Parameter Value in Kubelet on a Worker Node

Problem

How to Enable fail-on-swap=false option as a parameter value in Kubelet one a worker node.

Environment

  • Platform9 Managed Kubernetes - All Versions

Procedure

Steps to enable swap on a worker node.

  1. Start kubectl proxy in the background.

root@test-master1:~# kubectl proxy --port=8001 &
[1] 22409
root@test-master1:~# Starting to serve on 127.0.0.1:8001
  1. Current Configmap associated with the worker node.

root@test-master1:~# kubectl get node 172.20.4.210 -o yaml
...
spec:
configSource:
  configMap:
    kubeletConfigKey: kubelet
name: worker-default-kubelet-config
namespace: kube-system
...
  1. Download and unpackage the worker node configuration.

  1. Edit the config file named kubelet and change the failSwapOn parameter value to false and saved the file.

  1. Push the config file by creating a new ConfigMap. In this case, the configmap "new-worker-config-swapon" is created.

  1. Edit the worker node reference to point to the new ConfigMap.

  1. Post this you will observe that the pf9-kubelet service on the node will be restarted and a new checkpoint will be created in this case ca8caeaa-da7d-4d95-8fbb-6adac5795958 (Kubelet always refers to the newest created checkpoint when setting dynamic configuration). Note that initially when the service restarts you would see kubelet setting the swap value to "true" from its default configuration in kubelet logs but it will then load the newer configmap and set the value to false accordingly.

  1. In terms of memory allocation, the node's memory resource request/limit allocation will be honored but since the swap is not supported natively the way in which kubelet does the calculations might not be accurate leading to pod evictions due to memory.

Note: If the same change has to be made across all nodes, you can read more about it herearrow-up-right.

Additional Information

Last updated