报错:kubernetes初始化端口占用及文件存在(本人是之前初始化过一次)
[root@master ~]# kubeadm init --apiserver-advertise-address=192.168.20.200 --image-repository=registry.aliyuncs.com/google_containers --kubernetes-version=v1.28.0 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --cri-socket=unix:///var/run/cri-dockerd.sock
[init] Using Kubernetes version: v1.28.0
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR Port-6443]: Port 6443 is in use
[ERROR Port-10259]: Port 10259 is in use
[ERROR Port-10257]: Port 10257 is in use
[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
解决方法:
首先先清空上次初始化的产生的文件
rm -rf /etc/kubernetes/*
rm -rf /var/lib/etcd/*
rm -rf ~/.kube/*
下载这个包来停用被占用的端口
yum install lsof -y
停用被占用的端口
lsof -i:15909|grep -v "PID"|awk '{print "kill -9",$2}'|sh
重启
kubeadm reset
然后再初始化
kubeadm init
标签:初始化,kubernetes,yaml,--,manifests,etc,集群,ERROR
From: https://www.cnblogs.com/zmh520/p/18396567