Kubernetes 为什么kubeadm即使在禁用交换后也不启动?

Kubernetes 为什么kubeadm即使在禁用交换后也不启动?,kubernetes,kubectl,kubeadm,kubelet,Kubernetes,Kubectl,Kubeadm,Kubelet,我正在尝试在我的笔记本电脑中安装kubernetes和kubeadm,它有Ubuntu 16.04。我已经禁用了swap,因为kubelet无法在上使用swap。我使用的命令是: swapoff-a 我还注释掉了/etc/fstab中对swap的引用 # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; thi

我正在尝试在我的笔记本电脑中安装kubernetes和kubeadm,它有Ubuntu 16.04。我已经禁用了swap,因为kubelet无法在上使用swap。我使用的命令是:

swapoff-a

我还注释掉了
/etc/fstab
中对swap的引用

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>    <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=1d343a19-bd75-47a6-899d-7c8bc93e28ff /            ext4 errors=remount-ro 0    1
# swap was on /dev/sda5 during installation
#UUID=d0200036-b211-4e6e-a194-ac2e51dfb27d none         swap sw           0    0
当我启动kubeadm时,我得到以下错误:

kubeadm init --pod-network-cidr=10.244.0.0/16
[init] Using Kubernetes version: v1.14.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=...`

我也尝试重新启动我的笔记本电脑,但我得到了同样的错误。原因可能是什么?

您可以尝试
kubeadm重置
,然后
kubeadm初始化--忽略飞行前错误交换
首先尝试使用sudo

sudo swapoff -a
然后检查是否有任何交换

cat /proc/swaps


下面是根本原因

检测到“cgroupfs”作为Docker cgroup驱动程序。推荐的驱动程序为“systemd”

您需要更新docker cgroup驱动程序

遵循下面的修复

cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF

mkdir -p /etc/systemd/system/docker.service.d

# Restart Docker
systemctl daemon-reload
systemctl restart docker

cat>/etc/docker/daemon.json试过了。但库贝莱并没有开始。检查日志日志:`无法运行Kubelet:不支持在交换打开的情况下运行,请禁用交换!或者将--fail swap on标志设置为false`这可以工作。但不确定原因(IsDockerSystemCheck只是一个警告,而不是一个错误)。但为什么库比德还在说在我做这个改变之前交换已经打开了呢?不知道。
free -h
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF

mkdir -p /etc/systemd/system/docker.service.d

# Restart Docker
systemctl daemon-reload
systemctl restart docker