錯誤截圖:
錯誤代碼:
[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
在靜等一會后,終端會給出以下提示,按照提示執行: