kubeadm初始化时报错Swap,详细报错内容如下
[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=...`
|-----|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 | [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=...` |
这是因为swap导致的,两种解决办法:
一、关闭swap
swapoff -a sed -ri 's/.*swap.*/#&/' /etc/fstab
|-----|---------------------------------------------------| | 1 2 | swapoff -a sed -ri 's/.*swap.*/#&/' /etc/fstab |
二、通过参数忽略swap报错
在kubeadm初始化时增加--ignore-preflight-errors=Swap参数,注意Swap中S要大写
kubeadm init --ignore-preflight-errors=Swap
|---|---------------------------------------------| | 1 | kubeadm init --ignore-preflight-errors=Swap |
另外还要设置/etc/sysconfig/kubelet参数
sed -i 's/KUBELET_EXTRA_ARGS=/KUBELET_EXTRA_ARGS="--fail-swap-on=false"/' /etc/sysconfig/kubelet
|---|--------------------------------------------------------------------------------------------------| | 1 | sed -i 's/KUBELET_EXTRA_ARGS=/KUBELET_EXTRA_ARGS="--fail-swap-on=false"/' /etc/sysconfig/kubelet |
在以往老版本中是必须要关闭swap的,但是现在新版又多了一个选择,可以通过参数指定,忽略swap报错!