kubadm init error CPUs 1 is less than required 2
Asked Answered
C

5

7

Can anybody help me with this error. I have been following different links to install Kubernetes in centos 7 and I keep getting this error when i run the kubadm init command.

[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2               

Im not really sure what this means. I put the slave nodes IP in /etc/hosts/ file. Am I supposed to do something else. maybe add the node to a config file??? These are the links and steps I followed.

https://www.linuxtechi.com/install-kubernetes-1-7-centos7-rhel7/ https://github.com/justmeandopensource/kubernetes/blob/master/docs/install-cluster.md https://www.tecmint.com/install-kubernetes-cluster-on-centos-7/

Cofsky answered 22/3, 2020 at 19:57 Comment(0)
B
12

Kubeadm runs a series of pre-flight checks to validate the system state before making changes.This error means the host don't have minimum requirement of 2 CPU. You can ignore the error if you still want to go ahead and install kubernetes on this host.

kubeadm init --ignore-preflight-errors=NumCPU
Bovine answered 23/3, 2020 at 1:42 Comment(1)
Doing LFD259 lab exercises on Digital Ocean single CPU instances, and I needed to go on with the K8s installation. The command worked for me. Of course, I would not consider on a production environment.Hellraiser
O
5

The reason this is occurring is because the hardware on which you are installing Kubernetes does not have enough resources. The developers in the Kubernetes community have mutually agreed that running Kubernetes with less than 2 CPU Cores is not advisable.

This is because in order to run Kubernetes you have to account for a certain amount of overhead. And, when doing so, if you have a system with a very small amount of compute power you will not be able to properly run applications simultaneously.

@Arghya is correct. You can opt to circumvent this by ignoring the Pre-Flight check that evaluates the capabilities of your hardware before installing the software. However, this is not advisable due to what I explained above.

If you're curious about learning more about how CPU cores relate to Kubernetes and Linux Containers, here is some really good documentation. In a nutshell, a Linux Container is effectively a process that is partitioned off from the rest of the operating system by what is known as a Kernel Namespace. Furthermore, this process can have limitations or requirements set around the amount of memory and cpu it can consume by using Control Groups.

When running a Linux Container in Kubernetes, the Kubernetes API Server schedules pods on worker nodes based on their available resources. If a Pod requires 200m of CPU, for example, then you would have already allocated 20% of your hardware to a single process running on it. See how much this can impact the required overhead to run the software? Kubernetes itself provisions half a dozen pods just to run. All of which have CPU Limitations and Requests specified.

Here is a good doc if you want to learn more about how CPU resources are applied to containerized processes with Linux cgroups.

Onega answered 28/3, 2020 at 3:15 Comment(0)
O
5

You can use

kubeadm init --pod-network-cidr=30.320.0.0/16  --ignore-preflight-errors=NumCPU  --ignore-preflight-errors=Mem

or

kubeadm init --ignore-preflight-errors=all
Orban answered 22/6, 2021 at 12:37 Comment(0)
J
0

You can ignore this error as mentioned in error output as well.

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 NumCPU]: the number of available CPUs 1 is less than the required 2 [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

If you dont have much CPUs to use then go ahead, you can have a cluster but you will face issues. Otherwise allocate 2 CPUs minimum on master node to work smoothly.

Thanks

Janiuszck answered 14/12, 2020 at 12:7 Comment(0)
N
0

I ran into a similar problem on MacOS when starting minikube with Docker and VirtualBox. Assuming you have more than 1 CPU core, the way I solved this issue, I had to power off VirtualBox, opened it by typing VirtualBox in the terminal, and increased the number of CPUs from 1 to 2.

Step 1: Poweroff VirtualBox

for i in `vboxmanage list runningvms | awk '{print $1}' \
| sed 's/"//g'`; do vboxmanage controlvm $i poweroff; done

Step 2: Type VirtualBox from the terminal to open it. Then, adjust the number of CPUs

Step 3: Start VirtualBox by running:

VBoxManage startvm "default" --type headless

Step 4: try to run your command again, hopefully, this would have resolved the issue

Nanettenani answered 23/12, 2021 at 23:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.