반응형

[K8S] ## K8S 설치시 Trouble Shooting

- kubeadm init 했는데 다음과 같이 나오는 경우

[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

 

1. docker Cgroup 이 systemd 로 설정되어있을 경우

/etc/docker/daemon.json 파일에 아래 문구 추가한다.

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

그리고
systemctl daemon-reload
systemctl restart docker

2. 로그 확인

- 'journalctl -xeu kubelet' 

이 명령어를 실행 하면 아래와 같이 로그가 남았다. 

Apr 30 22:19:38 master kubelet: W0430 22:19:38.226441    2372 cni.go:157] Unable to update cni config: No networks found in /etc/cni/net.d
Apr 30 22:19:38 master kubelet: E0430 22:19:38.226587    2372 kubelet.go:2067] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

 

내 경우에는 위에 2.  /env/environment 설정 에 보면 **no_proxy** 항목에 현재 K8S 가 설치된 Machine 의 IP 를 추가했더니 해결이 되었다.

- kubeadm join 했는데 다음과 같이 나올 경우

[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
    [ERROR Port-10250]: Port 10250 is in use
    [ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

    VM 에서 다음과 같이 kubeadm join 을 했는데 에러가 났을경우 (node가 2개인데 2번째 노드 구성시)

    kubeadm reset 을 한번 실행하고 다시 join 명령어를 실행해준다.

728x90
반응형
반응형

현재 AWS  EC2 에 올라가 있는 ubuntu 에 kubernetes를 설치해 보았다. 

그런데 설치를 하다보니 프리티어로 받은 t2.micro 가지고는 너무 성능이 느렸다. 거의 접속도 못할 지경에 이르렀다. 그래서 어차피 설치하고 지울거니깐 t2.large로 올렸다.


설치 전에 Docker 가 먼저 설치 되어 있어야 한다.

(Docker 가 설치 안되어 있다면 https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository 여기 참고하거나 아래 링크 에도 내용은 나와있다.)


https://kubernetes.io/docs/setup/independent/install-kubeadm/


여기에 들어가보면 친절하게 설치 하는 방법을 찾을 수 있다.

내용을 살펴보면 Docker 설치도 포함하고 있어서 Docker 가 설치되어 있지 않다면 그대로 따라 하면 된다.


그리고 나는 Ubuntu 에 설치를 하니 아래와 같이 명령어를 실행 했다. 혹시 명령어 실행중 permission 에러가 나면 sudo 붙이고 실행 하면 된다.

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

이렇게 하면 kubelet, kubeadm, kubectl 이 설치가 된다.


https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/


그 다음 스텝으로 위 링크로 들어가서 클러스터를 생성 하면 된다.


여기 나와 있는 내용중에 보면 사양이 나와있다. 

  • One or more machines running a deb/rpm-compatible OS, for example Ubuntu or CentOS
  • 2 GB or more of RAM per machine. Any less leaves little room for your apps.
  • 2 CPUs or more on the master
  • Full network connectivity among all machines in the cluster. A public or private network is fine.

최소 사양이다. 이러니 t2.micro 로는 역부족이었다.

kubeadm init <args> 

이렇게 명령어를 날리면 뭔가 내용이 올라오면서 설치가 된다. args는 다양하게 있으나 나는 우선 필요가 없어서 안 넣었다. 설치가 완료되면 아래와 같은 내용들이 나온다. (ip랑 port, 토큰 부분은 ㅌㅌㅌ로 처리했다.)


Your Kubernetes master 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


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/


You can now join any number of machines by running the following on each node

as root:


  kubeadm join <ip>:<port> --token ㅌㅌㅌㅌㅌㅌㅌㅌ --discovery-token-ca-cert-hash sha256:ㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌ


잘 읽어보면 cluster 시작하려면 .kube에 config 파일을 만들라는 내용이 있다. 아주 편리하게 저 내용을 그대로 복사해서 붙여넣으면 된다. 그리고 아래 join에 나오는 내용은 잘 복사해서 저장해두자.


이렇게 하고 "kubectl get pods --all-namespaces" 라고 치면 아래와 비슷하게 나온다. 


NAMESPACE     NAME                                       READY     STATUS    RESTARTS   AGE

kube-system   coredns-78fcdf6894-86s7n                   0/1       Pending   0          7m

kube-system   coredns-78fcdf6894-ngk7x                   0/1       Pending   0          7m

kube-system   etcd-ip-172-31-22-134                      1/1       Running   0          7m

kube-system   kube-apiserver-ip-172-31-22-134            1/1       Running   0          7m

kube-system   kube-controller-manager-ip-172-31-22-134   1/1       Running   0          6m

kube-system   kube-proxy-46x54                           1/1       Running   0          7m

kube-system   kube-scheduler-ip-172-31-22-134            1/1       Running   0          6m


그리고 위에도 써있듯이 cluster에 network를 배포해야 한다. 

위 링크(https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#pod-network 또는 https://kubernetes.io/docs/concepts/cluster-administration/addons/) 따라가보면 종류별로 방법이 있다. 설치하고 나서 다음과 같이 확인 해보면 된다.


 kubectl get nodes

NAME               STATUS    ROLES     AGE       VERSION

ip-111-11-11-111   Ready     master    32m       v1.11.2


아직 node 를 추가 못해봤는데 다음에는 node 도 따로 추가해봐야겠다.


728x90
반응형

+ Recent posts