Fixing a Common Kubernetes Init Error🔧

Aum Patel
2 min readAug 31, 2024

--

Ran into this issue today while setting up Kubernetes on my machine:

aum@omen:~/Desktop/cka$ sudo kubeadm init
[init] Using Kubernetes version: v1.31.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-2379]: Port 2379 is in use
[ERROR Port-2380]: Port 2380 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
...

Turns out, there was service was running as kubelet.service but it was not creating issue i already stopped it but noting changed. it was already running from my snap service, which I realised late in the game! 🤦‍♂️

To diagnose:

  1. Checked the process using the port with :
sudo lsof -i :10250

kubelet 67630 root 26u TCP *:10250 (LISTEN)

2. Verified it with ps -e | grep kubelet and found the kubelet process.

Tried killing the process, but it kept respawning. 🌀

Finally, traced it back to the snap service:

systemctl status snap.kubelet.daemon.service
systemctl stop snap.kubelet.daemon.service
systemctl disable snap.kubelet.daemon.service

Kubelet was managed by this service all along! 🕵️‍♂️ Lesson learned: Always check your services running on that port and use only one primary package manager. 🚀
#Kubernetes #DevOps

--

--

Aum Patel
Aum Patel

Written by Aum Patel

Devops | CKA | Penetration tester (EJPTV2) | Cloud Associate

No responses yet