'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?



Solution 1:[1]

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.

Solution 2:[2]

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

Solution 3:[3]

Check the process which uses Port 10250,

sudo netstat -lnp | grep 10250

Kill the process using

sudo kill Process_PID

then run kubeadm init .

Solution 4:[4]

You can use --port <port number> to override the port number for kublet.

For more information refer this: https://kubernetes.io/docs/admin/kubelet/

Solution 5:[5]

Make sure that kubelet is not installed twice.

Remove it from snap:

snap remove kubelet

Solution 6:[6]

Maybe ubuntu has installed some snap package. check it:

snap services

if you see some app like microk8 or etcd or ... there may be conflict. so:

sudo snap stop microk8s
sudo snap disable microk8s

sudo snap stop docker.dockerd
sudo snap disable docker

sudo snap stop etcd
sudo snap disable etcd

Solution 7:[7]

Once you run Kubeadm init it will reserve the ports and if any failure occurs after that then it won't automatically release those ports

Sof if you initially ran

sudo kubeadm init

and it failed then reset the kubeadm by running

sudo kubeadm reset

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jzeef
Solution 2 Hasitha
Solution 3 snehal
Solution 4 Rama Boggarapu
Solution 5 Unique_boy96
Solution 6 M.Namjo
Solution 7 Shithanshu