siderolabs / talos

Talos Linux is a modern Linux distribution built for Kubernetes.
https://www.talos.dev
Mozilla Public License 2.0
6.44k stars 514 forks source link

Swap disk/file #4440

Open sergelogvinov opened 2 years ago

sergelogvinov commented 2 years ago

Feature Request

Make possible to add swap disk/file to the system at boot time.

Description

When memory is not enough or memory pressure, system processes need a few extra memory to finish some jobs/gracefully stop pods etc. A small swap disk can help with that.

Proposal:

# example
machine:
  swap:
     disk: /dev/sda
     # or
     size: 1Gb

The swap can be disk/partition (azure has special disk for swap) or file in ephemeral storage. Swap has to be alway encrypted. The encryption key is auto generated at boot time. Sysctl param sets to vm.swappiness=1

If disk param is not set - Talos creates a swap-file with defined size.

disk and size cannot be set in the same time(?)

andrewrynhard commented 2 years ago

It is explicitly called out in the Kubernetes docs to disable swap.

ammmze commented 2 years ago

v1.22 brings alpha support for swap...so I think there is still some validity to this request.

smira commented 2 years ago

Notes from planning meeting

:+1:

abckey commented 2 years ago

any update on this ?

smira commented 2 years ago

any update on this ?

no plans for it so far, even though it should be relatively trivial to implement

Max-Sum commented 1 year ago

Are we getting this feature soon?

samos667 commented 10 months ago

https://kubernetes.io/blog/2023/08/24/swap-linux-beta/

It would be really great to be able to do that, with the possibility of using ZRAM in the best of all worlds.

septatrix commented 3 months ago

I also like to advocate for ZRAM as it offers many of the advantages of swap (move out barely used pages, better OOM handling) without any of the disadvantages (slow, many disk writes)

stevefan1999-personal commented 1 month ago

This is also now needed for specific scenario of using budget VPSes to deploy Talos, even just as a worker, #9037 is a particular case where image pulling can cause OOM and eventually kill containerd, making the whole installation process stuck