...

[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


 kubeadm init  로 초기화 시에 발생한 오류이다. 에러 메시지와 달리 kubelet 은 running 상태여서 원인을 파악하기가 힘들었다. 포트 inbound, swap 등 괜한 것만 건드리다가 cgroup 에서 원인을 찾았다.


결론은 컨테이너 런타임(docker) 및 kubelet 의 cgroup-driver 가 일치하지 않아서 발생한 오류였다. 정확한 에러 메시지도 아니고, 이게 warning 이 아니라 설치가 중단될 정도의 문제라는 것이 이상했지만 어쨌든 cgroup-driver 를 systemd 로 통일하여 해결했으니... docker 의 기본 cgroup-driver 는 cgroupfs 이고, kubelet 의 기본 cgroup-driver 는 systemd 라서 두 개의 다른 cgroup 관리자가 존재하게 되어, 리소스 부족으로 시스템이 불안정해 진다고 한다.



Docker cgroup driver 변경


docker 를 아래와 같이 설치하고 kubeadm init 를 다시 실행해 본다.


# apt-get update


// Install https

# apt-get update && apt-get install apt-transport-https ca-certificates curl software-properties-common


// Add Docker’s official GPG key

# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -


// Add docker apt repository

# add-apt-repository \

"deb [arch=amd64] https://download.docker.com/linux/ubuntu \

$(lsb_release -cs) \

stable"


// Install docker ce.

# apt-get update && apt-get install docker-ce=18.06.2~ce~3-0~ubuntu


// Setup daemon.

# cat > /etc/docker/daemon.json <<EOF

{

  "exec-opts": ["native.cgroupdriver=systemd"],

  "log-driver": "json-file",

  "log-opts": {

    "max-size": "100m"

  },

  "storage-driver": "overlay2"

}

EOF


# mkdir -p /etc/systemd/system/docker.service.d

# systemctl daemon-reload

# systemctl restart docker



Kubelet cgroup driver 변경


다른 방법으로 kubelet 의 cgroup driver 를 변경하는 방법도 있다.


# vi /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

...

[Service]

ExecStart=

ExecStart=/usr/bin/kubelet --fail-swap-on=false --authorization-mode=Webhook --client-ca-file=/var/lib/minikube/certs/ca.crt --kubeconfig=/etc/kubernetes/kubelet.conf --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --hostname-override=minikube --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --cgroup-driver=cgroupfs --container-runtime=docker

...




WRITTEN BY
손가락귀신
정신 못차리면, 벌 받는다.

,