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.
- Start kubectl proxy in the background.
- Current Configmap associated with the worker node.
- Download and unpackage the worker node configuration.
- Edit the config file named
kubelet
and change thefailSwapOn
parameter value to false and saved the file.
- Push the config file by creating a new ConfigMap. In this case, the configmap "new-worker-config-swapon" is created.
- Edit the worker node reference to point to the new ConfigMap.
- 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.
- 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 here.
Additional Information
- Enabling swap on a node in Kubernetes supported starting K8s v1.22. Reference: https://kubernetes.io/blog/2021/08/04/kubernetes-1-22-release-announcement/#node-system-swap-support
- From Platform9's perspective, a feature request PMK8-I-148 has been created to look into ways and options in which we can expose an option to enable the fail-on-swap=false as a feature flag in the cluster creation wizard.
Was this page helpful?