<p>I am new at kubeletes and I can´t run "kubeadm init" with success.</p>

<p>Let me show you step by step what I did:</p>

<ol>
<li><p>I installed last version dockers using yum following dockers documentation
(I have configurated 'Environment="HTTP_PROXY=<a href="http://usuario:password@proxy:port/" rel="nofollow noreferrer">http://usuario:password@proxy:port/</a>" "HTTPS_PROXY=<a href="http://usuario:password@proxy:port/" rel="nofollow noreferrer">http://usuario:password@proxy:port/</a>"' in /etc/systemd/system/docker.service.d/http-proxy.conf).</p></li>
<li><p>I have disabled SELINUXTYPE, disabled Swap with the command "swapoff -a" and commented "#/dev/mapper/centos-swap swap swap defaults 0 0" in /etc/fstab.</p></li>
<li><p>I used "modprobe br_netfilter" and "echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables" to activate the module called "br_netfilter".</p></li>
<li><p>"kubernetes.repo" file to install "kubelet kubeadm kubectl" using yum:</p>

<pre><code>[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
</code></pre></li>
<li><p>Opened ports:</p>

<pre><code> firewall-cmd --permanent --add-port=6443/tcp
 firewall-cmd --permanent --add-port=2379-2380/tcp
 firewall-cmd --permanent --add-port=10250/tcp
 firewall-cmd --permanent --add-port=10251/tcp
 firewall-cmd --permanent --add-port=10252/tcp
 firewall-cmd --permanent --add-port=10255/tcp
 firewall-cmd --reload
</code></pre></li>
<li><p>I created "10-kubeadm.conf" file:</p>

<pre><code> [Service]
 Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
 Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
 # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
 EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
 # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
 # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
 EnvironmentFile=-/etc/sysconfig/kubelet
 ExecStart=
 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
</code></pre></li>
<li><p>Reload and enable services:</p>

<pre><code> systemctl daemon-reload
 systemctl restart docker
 systemctl enable docker
 systemctl restart kubelet
 systemctl enable kubelet
</code></pre>

<p>(both services with status: active(running))            </p></li>
</ol>

<p>Error:</p>

<pre><code>[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.

Unfortunately, an error has occurred:
    timed out waiting for the condition

This error is likely caused by:
    - The kubelet is not running
    - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
    - 'systemctl status kubelet'
    - 'journalctl -xeu kubelet'

Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
Here is one example how you may list all Kubernetes containers running in docker:
    - 'docker ps -a | grep kube | grep -v pause'
    Once you have found the failing container, you can inspect its logs with:
    - 'docker logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
</code></pre>

<p>Thanks in advance for the help.</p>

<p>Best Regards.</p>

Gonzalo Colino Alonso
<p>please disable your swap</p>

<pre><code>swapoff -a

vim /etc/fstab
</code></pre>

<p>comment the swap line
after that install this packages</p>

<pre><code>yum install -y yum-utils device-mapper-persistent-data lvm2
</code></pre>

<p>and add repo by this</p>

<pre><code>yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
</code></pre>

<p>and you should install docker by this command</p>

<pre><code>yum install -y docker-ce


cat &lt;&lt;EOF &gt; /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

yum install -y kubelet kubeadm kubectl
</code></pre>

<p>then reboot</p>

<pre><code>systemctl start docker &amp;&amp; systemctl enable docker
systemctl start kubelet &amp;&amp; systemctl enable kubelet


systemctl daemon-reload
systemctl restart kubelet

kubeadm init --apiserver-advertise-address=MASTER_IP --pod-network-cidr=10.244.0.0/16
</code></pre>

<p><strong>do not change 10.244.0.0/16</strong></p>

<pre><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
</code></pre>

<p>Next, deploy the flannel network to the kubernetes cluster using the kubectl command.</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
</code></pre>

<p>I write the complete way to run kubernetes and I run kubernetes cluster by this command 1000 of time</p>
