Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubeadm fails to initialize when kubeadm init is called

I am new to kubernetes and trying to configure kubernetes master node, I have installed kubeadm, kubectl and kubelet following

https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

but when I try to start kubeadm by typing kubeadm init, it gives me the following error

[init] Using Kubernetes version: v1.14.0
[preflight] Running pre-flight checks
        [WARNING Firewalld]: no supported init system detected, skipping checking for services
        [WARNING Service-Docker]: no supported init system detected, skipping checking for services
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
        [WARNING Service-Kubelet]: no supported init system detected, skipping checking for services
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 FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
like image 326
abhishek Avatar asked Apr 05 '19 09:04

abhishek


People also ask

Can I run Kubeadm init again?

kubeadm reset will not delete any etcd data if external etcd is used. This means that if you run kubeadm init again using the same etcd endpoints, you will see state from previous clusters. See the etcd documentation for more information.


2 Answers

It seems you have stale data present on the system. To remove that data (/etc/kubernetes) directory run:

kubeadm reset

Now you need to set ip_forward content with 1 by following command:

echo 1 > /proc/sys/net/ipv4/ip_forward

This should resolve your issue.

like image 99
Prafull Ladha Avatar answered Jan 03 '23 20:01

Prafull Ladha


The br_netfilter module is required for kubernetes installation. Enable this kernel module so that the packets traversing the bridge are processed by iptables for filtering and for port forwarding, and the kubernetes pods across the cluster can communicate with each other.

Run the command below to enable the br_netfilter kernel module.

#modprobe br_netfilter


#echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables  

or

#nano /proc/sys/net/ipv4/ip_forward

you should see 0 delete 0 and write 1

like image 26
yasin lachini Avatar answered Jan 03 '23 20:01

yasin lachini