Question

Is it possible to enable swap for Kubernetes nodes?

Posted June 18, 2019 5.4k views
Kubernetes

There doesn’t seem to be an option to choose a distribution when setting up a node pool, which is understandable, as I’m sure Kubernetes has special requirements. But it seems that you can’t SSH into Kubernetes nodes, which again is understandable as that’s the point of Kubernetes and especially managed Kubernetes.

So I suspect the answer to my question is no. But it seems like such a simple little feature that could lead to more robust workloads and clusters.

1 comment
  • this is my story:
    I tried to migrate github action to k8s using https://github.com/summerwind/actions-runner-controller , it supports autoscale runner by pending pull request on-demand. But the runner processed is killed by the system when it tries to build rust project because the llvm eating pod’s whole memory,it was useless to upgrade the machine to 64G。 the only way is to increment the node’s swap, but the swap option needs the cloud service provider to support it, I can not do it by myself.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
4 answers

Tom,

Thanks for the feedback. I in no way meant to assume that swap wasn’t convenient or at times necessary on a Linux system. I spent many years as a sysadmin and now lead product for DOKS, so I was framing it to try to understand your specific use case so that I could potentially work it in to our roadmap (as an option during cluster creation). Having your feedback about use case would make it easier for me to sell to the engineering team. I definitely did not have money in mind, but performance. In a lot of cases on a high performance system you’d want to evict a workload or scale your cluster to ensure top performance as opposed to extensive monitoring on swap usage or slow responses. Thanks for your feedback, I will run it by the team and update this when I have more information.

Regards,
Phil

Hi Tom,

Thanks for your question! At this time we do not enable swap on DOKS worker nodes. Can you explain a bit more about what types of workloads you would like to run that would utilize swap instead of more memory?

That’s good to know that it’s not officially supported yet, thank you.

However, it’s hard to take your question seriously. I can only take it to mean that your primary concern is for DO sales. Swap memory is such a fundamental concept in computing and has such a myriad of use cases that the only reason I can think that you would ask what workloads I might need it for is that DO would rather not lose the economic opportunity of customers solving their memory needs with profit making RAM. I’m sorry to be so cynical.

You didn’t need to frame your question like that. You could have simply said that DO appreciates the value of Swap but has yet to implement it in a reliable manner. I would have been satisfied with that answer.

But to spell it out: Swap is slow RAM, it replaces system crashes with infinitely preferable system slowness. It should not be a replacement for RAM but because of the profound difference between crashing and slowness I can not think of single situation where Swap should not be enabled by default on a system.

Hi,

Any news on that matter? I’m having a similar problem where my GitLab runner is killed because of heavy needs for RAM by webpack minification during the build. Having a BIG node for running 4 project builds per day is not very cost-effective :D So I would love to see some optional swap on k8s nodes. I hope it is something easy to do and one day we will see it.

Best regards
Piotr