Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use kubeadm to create kubernetes cluster?

I init k8s cluster master with kubeadm, but I felt very confused. The version of kubeadm:

# ./kubeadm version
kubeadm version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:52:01Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

When I run command with kubeadm init, told me must start kubelet.service:

# ./kubeadm init
Running pre-flight checks
preflight check errors:
    kubelet service is not active, please run 'systemctl start kubelet.service'

And then When I retry this command after systemctl restart kubelet.service, told me Port 10250 in use:

# systemctl restart kubelet.service
# ./kubeadm init
Running pre-flight checks
preflight check errors:
    Port 10250 is in use
    /var/lib/kubelet is not empty

Is there any way to run kubelet with no port OR can I change the port of kubelet?

like image 738
sope Avatar asked Jan 19 '17 01:01

sope


3 Answers

The reason that it mentions the port is in use is because you already ran kubeadm init once and it has already changed a number of things.

run kubeadm reset first to undo all of the changes from the first time you ran it.

Then run systemctl restart kubelet

Finally, when you run kubeadm init you should no longer get the error.

Any time kubeadm does something that's not right or otherwise fails, it needs to be reset to work properly again.

like image 59
jzeef Avatar answered Nov 10 '22 09:11

jzeef


Check the process which uses Port 10250,

sudo netstat -lnp | grep 10250

Kill the process using

sudo kill Process_PID

then run kubeadm init .

like image 45
snehal Avatar answered Nov 10 '22 09:11

snehal


I also had same problem.

error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR Port-10251]: Port 10251 is in use
    [ERROR Port-10252]: Port 10252 is in use
    [ERROR Port-10250]: Port 10250 is in use
    [ERROR Port-2380]: Port 2380 is in use

then i noticed that there is another process is running "microk8s" once I stopped that, I was able to start kubeadm

sudo microk8s.stop
like image 11
Hasitha Avatar answered Nov 10 '22 10:11

Hasitha