Almost-Native

kubeadm init 실행시 에러 : 'curl -sSL http://localhost:10248/healthz' failed with error 본문

Java 프로그램 개발, IT

kubeadm init 실행시 에러 : 'curl -sSL http://localhost:10248/healthz' failed with error

2022. 1. 6. 12:11

쿠버네티스 설치하고 kubeadm init 커맨드 실행시 다음과 같은 에러를 만나는 경우가 있습니다.

 

[root@ol8k8s ~]# kubeadm init
[init] Using Kubernetes version: v1.23.1
...
[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.
[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 [::1]:10248: connect: connection refused.
[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 [::1]:10248: connect: connection refused.
[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 [::1]:10248: connect: connection refused.
[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 [::1]:10248: connect: connection refused.
[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 [::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
 
 

 

kubelet 이 제대로 동작하지 않고 있는 것 같은 에러메시지 입니다.

 

인터넷을 뒤지다 아래와 같은 해결책을 발견하게 되었습니다.

/etc/docker 디렉토리에 daemon.json 파일을 아래와 같이 만들어줍니다.

 

sudo mkdir /etc/docker

cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
 
sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker

 

위 조치 방법은 쿠버네티스 공식 홈페이지에 나와 있는 내용 그대롭니다.

  => https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker

 

사실은, 원래 쿠버네티스 설치전에 Container runtime 을 먼저 설치해줘야 하는데(여기서는 docker 부분..)

이 부분을 빠뜨리고 진행한 경우 이런 에러상황을 만나게 되는 겁니다.

 

위와 같이 daemon.json 파일을 만들어주고나서, kubeadm reset 하고 init 해주니 정상적으로 잘 되네요~

 

> kubeadm reset
> kubeadm init

 

[root@ol8k8s docker]# kubeadm init
[init] Using Kubernetes version: v1.23.1
...
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy
 
Your Kubernetes control-plane has initialized successfully!
 
To start using your cluster, you need to run the following as a regular user:
 
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config
 
Alternatively, if you are the root user, you can run:
 
  export KUBECONFIG=/etc/kubernetes/admin.conf
 
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/
 
Then you can join any number of worker nodes by running the following on each as root:
 
kubeadm join 192.168.1.161:6443 --token m1hgjw.x29p8uzvm56khmw3 \
        --discovery-token-ca-cert-hash sha256:192014ce0d76b9ba32d4e6e42a1322f82e060fa689bf2486e606f660fd013ec5
 

 

 

Comments