K8S拉取镜像失败解决方法To see the stack trace of this error execute with --v=5 or higher
错误截图:
错误代码:
[root@localhost ~]# kubeadm init --config init-kubeadm.conf
[init] Using Kubernetes version: v1.20.0
[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/
[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.1. Latest validated version: 19.03
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
[root@localhost ~]#
错误翻译截图:
解决方法:
编辑 hosts
文件,直接指定其IP访问即可。
如果该IP失效,也可以去 https://githubusercontent.com.ipaddress.com/raw.githubusercontent.com 获取新的IP:
sudo vi /etc/hosts
在最后一行写入:
199.232.4.133 raw.githubusercontent.com
关闭防火墙
需要关闭防火墙,确保可以自由访问端口
systemctl stop firewalld & systemctl disable firewalld
关闭 swap
#临时关闭 swapoff -a # 永久关闭 vi /etc/fstab
注释以下代码
/dev/mapper/centos-swap swap ...
关闭 selinux
# 暂时关闭 selinux setenforce 0 # 永久关闭 需重启 vi /etc/sysconfig/selinux # 修改以下参数,设置为disable SELINUX=disabled
为什么关闭防火墙,selinux,swap?可以看这里:https://www.zhihu.com/question/374752553
然后重新拉取即可成功:
初始化K8S
kubeadm init --config init-kubeadm.conf
在静等一会后,终端会给出以下提示,按照提示执行: