Minikube不能成功启动的报错分析及解决方案
Minikube启动前需要对系统环境进行初始化:
# 启用docker服务
sudo systemctl enable docker.service
# 关闭防火墙
sudo systemctl stop firewalld
# 关闭内存交换
sudo swapoff -a
# 修改为cgroupfs
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
# 重新加载配置
systemctl daemon-reload
# 重启docker
systemctl restart docker
# 关闭selinux
sudo setenforce 0
# 文件权限
sudo chmod -R 777 /etc/kubernetes/addons/
# 启动kubelet服务,注意:可能需要第一次允许minikube start后才会拉取kubelet
systemctl enable kubelet.service
初始化时的报警:
- 在使用kubeadm init命令初始化节点刚开始时,会有如下的perflight阶段,该阶段会进行检查,如果其中出现了如下WARNING并且初始化失败了。下面会对下述几个警告进行解决:
# kubeadm init ...
[init] Using Kubernetes version: v1.15.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 FileExisting-socat]: socat not found in system path
WARNING IsDockerSystemdCheck
解决办法:修改或创建/etc/docker/daemon.json,加入下述内容:
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
重启docker:
systemctl daemon-reload
systemctl restart docker
查看修改后的状态:
docker info | grep Cgroup
2. WARNING FileExisting-socat
socat是一个网络工具, k8s 使用它来进行 pod 的数据交互,出现这个问题直接安装socat即可:
yum install -y socat
3. WARNING Firewalld
[WARNING Firewalld]: firewalld is active, please ensure ports [8443 10250] are open or your cluster may not function correctly
解决办法:
## 暂时关闭防火墙
systemctl stop firewalld.service
##永久关闭
systemctl disable firewalld.service
4.WARNING Service-Docker
[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
解决办法:
systemctl enable docker.service
5.WARNING Service-Kubelet
[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
解决办法:
systemctl enable kubelet.service
6.WARNING Swap
[WARNING Swap]: running with swap on is not supported. Please disable swap
解决办法:
swapoff -a
7.SELINUX未关闭
Problems detected in kube-addon-manager [13ce287ce3f6]:
error: Error loading config file "/var/lib/minikube/kubeconfig": open /var/lib/minikube/kubeconfig: permission denied
error: Error loading config file "/var/lib/minikube/kubeconfig": open /var/lib/minikube/kubeconfig: permission denied
error: Error loading config file "/var/lib/minikube/kubeconfig": open /var/lib/minikube/kubeconfig: permission denied
解决办法:
setenforce 0
或尝试永久关闭SELINUX
8.ERROR FileContent–proc-sys-net-bridge-bridge-nf-call-iptables
[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
解决办法:
echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables