k8s를 설치하거나, 설치 후 재부팅 시 생기는 에러이다.
공식문서나 여러 블로그에서 k8s install 을 따라하였으나 어떠한 이유에서인지 계속 발생한다.
원인이 여러가지가 있어 정리하여 올려둔다.
1. The Kubeconfig environmental variable is probably not set.
export KUBECONFIG=/etc/kubernetes/admin.conf or $HOME/.kube/config
2. The user’s $HOME directory has no .kube/config file. If you don’t have a .kube or config file
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf HOME/.kube/config sudo chown (id -u):$(id -g) $HOME/.kube/config
#Alternatively you can also export KUBECONFIG variable like this:
export KUBECONFIG=$HOME/.kube/config
3. swap & kubelet problem
#Kubelet service may be down. This may be due to the fact that swap is enabled.
sudo swapoff -a`
#To make it permanent
sudo -i
swapoff -a
exit
strace -eopenat kubectl version
sudo systemctl restart kubelet.service
4. docker service may be down
sudo systemctl start docker
5. firewall block access
sudo systemctl status firewalld #redhat centos
sudo systemctl stop firewalld #redhat, centos
sudo ufw status verbose #ubuntu
sudo ufw disable #ubuntu
사실 2번까지는 k8s install 시 수행을 하고, 3번 또한 수행하지만 컴퓨터마다 다른지 permanant가 적용되지 않는 환경이 존재하는 듯 하다. 각 단계를 진행하고 kubectl
이 먹히는지 테스트 해보는 것이 좋다. 나는 3번 과정으로 에러를 해결했다.