K8s 常见问题及解决办法

导读:本篇文章讲解 K8s 常见问题及解决办法,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

一、使用 kubeadm 初始化k8s集群时报错

this Docker version is not on the list of validated version:20.10.18. Latest validated version:19.03:

K8s 常见问题及解决办法

# 如果kubernets初始化时失败后,第二次再次执行会初始化命令会报错,这时需要进行重置
[init] Using Kubernetes version: v1.20.9
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml]: /etc/kubernetes/manifests/kube-apiserver.yaml already exists
	[ERROR FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml]: /etc/kubernetes/manifests/kube-controller-manager.yaml already exists
	[ERROR FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml]: /etc/kubernetes/manifests/kube-scheduler.yaml already exists
	[ERROR FileAvailable--etc-kubernetes-manifests-etcd.yaml]: /etc/kubernetes/manifests/etcd.yaml already exists
	[ERROR Port-10250]: Port 10250 is in use
	[ERROR DirAvailable--var-lib-etcd]: /var/lib/etcd is not empty
[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

解决办法:

#1. 查看当前docker版本
docker version

#2. 查看当前仓库支持的docker版本
yum list docker-ce --showduplicates | sort -r

#3. 降低docker版本到19.03.9.ce-3.el7
yum downgrade --setopt=obsoletes=0 -y docker-ce-19.03.9-3.el7 docker-ce-cli-19.03.9-3.el7 containerd.io

#4. 再次查看docker 版本是否为19.03
docker version

#5.  修改为docker 和 k8s 的 cgroup driver 一致,k8s 的是 systemd ,而 docker 是cgroupfs。三台机子都要修改:

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

systemctl restart docker

#6. 重置
kubeadm reset

#7. 再次初始化即可

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/74591.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!