14

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=...`
Eduardo Baitello
  • 10,469
  • 7
  • 46
  • 74
abhishek
  • 163
  • 1
  • 1
  • 7

3 Answers3

25

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.

Prafull Ladha
  • 12,341
  • 2
  • 37
  • 58
3

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

yasin lachini
  • 5,188
  • 6
  • 33
  • 56
0

It's an old question, and the OP was not asking about ansible, but since I've found this question searching for this error, but using an ansible playbook, I add it here for others like me.

With Ansible you can do:

- ansible.posix.sysctl:
  name: net.ipv4.ip_forward
   value: '1'
   sysctl_set: true

ref: https://docs.ansible.com/ansible/latest/collections/ansible/posix/sysctl_module.html

Nicolas
  • 571
  • 6
  • 13