kubeadm init error: ‘curl -sSL http://localhost:10248/healthz’ failed with error

Solved3.46K viewskubeadm kubelet kubernetes ubuntu

kubeadm init error: ‘curl -sSL http://localhost:10248/healthz’ failed with error

I am trying to initialize a Kubernetes cluster with kubeadm

kubeadm init --apiserver-advertise-address=172.31.26.215 --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors all

It is failing with the below error

[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
         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.
         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
To see the stack trace of this error execute with --v=5 or higher

I have installed Kubernetes on AWS ec2 ubuntu instance and it shows Kubernetes version v1.22.0. Checking kubelet status shows the below output

[email protected]:/home/ubuntu# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
     Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/kubelet.service.d
             └─10-kubeadm.conf
     Active: activating (auto-restart) (Result: exit-code) since Mon 2021-08-09 08:32:09 UTC; 5s ago
       Docs: https://kubernetes.io/docs/home/
    Process: 14538 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE)
   Main PID: 14538 (code=exited, status=1/FAILURE)
 Aug 09 08:32:09 ip-172-31-26-215 systemd[1]: kubelet.service: Main process exited, code=exited, status=1/FAILURE
Aug 09 08:32:09 ip-172-31-26-215 systemd[1]: kubelet.service: Failed with result 'exit-code'.

Any help will be appreciated.

Share:
vito Selected answer as best September 6, 2021
0

I figured out the issue. The issue is with kubernetes version 1.22. Installing an old version (v1.20.2) will resolve this problem.

sudo apt-get install -y kubelet=1.20.2-00 kubeadm=1.20.2-00 kubectl=1.20.2-00

Complete commands:

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet=1.20.2-00 kubeadm=1.20.2-00 kubectl=1.20.2-00
sudo apt-mark hold kubelet kubeadm kubectl

Share:
vito Selected answer as best September 6, 2021
0
You are viewing 1 out of 1 answers, click here to view all answers.