swapoff: /swapfile: swapoff failed: Cannot allocate memory

11/7/2019

I am getting below error while running kubeadm init :

[init] Using Kubernetes version: v1.16.2
[preflight] Running pre-flight checks
    [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

sudo swapoff -a swapoff: /swapfile: swapoff failed: Cannot allocate memory

I am using Ubuntu VM in parallel desktop

free -m command output below: $ free -m total used free shared buff/cache available Mem: 979 455 87 1 436 377 Swap: 2047 695 1352

-- Penguin Tech
kubernetes
linux
parallels
ubuntu-18.04

1 Answer

11/7/2019

You do not have enough RAM. Your machine is surviving because you use a swap file (i.e. using your hard drive for extra pseudo-RAM) but that is not supported by Kubernetes so it tried to turn that off which failed because you don't have enough RAM.

-- coderanger
Source: StackOverflow