kubernetes - 为什么即使禁用交换后 kubeadm 也无法启动?
问题描述
我正在尝试在具有Ubuntu 16.04的笔记本电脑上安装带有 kubeadm 的 kubernetes 。我禁用了交换,因为 kubelet 不能与交换一起工作。我使用的命令是:
swapoff -a
我还注释掉了对 swap in 的引用/etc/fstab
。
# /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
我通过运行以下命令确认交换已关闭:
free -m
total used free shared buff/cache available
Mem: 15936 2108 9433 954 4394 12465
Swap: 0 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=...`
我也尝试重新启动我的笔记本电脑,但我得到了同样的错误。可能是什么原因?
解决方案
以下是根本原因。
检测到“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
推荐阅读
- javascript - Onclick 与 window.onload 功能
- c# - 插入语句与外键 EF Core 多对多冲突
- android-studio - 整数作为条件 - Android Studio
- javascript - 如何在 VS 代码片段中插入表格?
- php - 如何在 PHP 中生成多个数组中所有可能的项目选择以缓存过滤系统
- javascript - d3.create() 返回带有 .node() 的元素,但不显示在浏览器中
- postgresql - Postgres 数据库“查询没有结果数据的目的地”错误
- azure-devops - 从私有 nuget 提要中删除外部 nuget 包
- python - 如何将数字转换为其对应的字母
- vb.net - WINDOWS 表格中的表格填充