Kubernetes
[Kubernetes] Worker node Trouble Shooting
heed159
2023. 6. 1. 11:04
Kubernetes 클러스터 구축 후 Worker node에서 kubectl get pods --all-namespaces 실행 시 에러가 발생하였다.
[root@k8s-node1 ~]# kubectl get pods --all-namespaces
E0601 10:55:18.184367 7412 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: c
E0601 10:55:18.186407 7412 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: c
E0601 10:55:18.188407 7412 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: c
E0601 10:55:18.190490 7412 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: c
E0601 10:55:18.191843 7412 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: c
The connection to the server localhost:8080 was refused - did you specify the right host or port?
위의 에러가 발생한 이유는 다음과 같다.
- Kubernetes Config 파일이 $HOME/.kube 디렉터리 아래에 존재하지 않을 때
- 현재 유저 정보가 Kubernetes Config 파일에 반영되지 않았을 때
아래 명령문으로 에러 해결
[root@k8s-node1 ~]# mkdir -p $HOME/.kube
[root@k8s-node1 ~]# cp -i /etc/kubernetes/kubelet.conf $HOME/.kube/config
[root@k8s-node1 ~]# chown $(id -u):$(id -g) $HOME/.kube/config
정상 작동 확인
[root@k8s-node1 ~]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-8n7x6 1/1 Running 0 6d21h
kube-flannel kube-flannel-ds-f4n8x 1/1 Running 0 6d21h
kube-flannel kube-flannel-ds-mjl5m 1/1 Running 0 6d21h
kube-system coredns-5d78c9869d-gltc5 1/1 Running 0 6d21h
kube-system coredns-5d78c9869d-js7sz 1/1 Running 0 6d21h
kube-system etcd-k8s-master 1/1 Running 0 6d21h
kube-system kube-apiserver-k8s-master 1/1 Running 0 6d21h
kube-system kube-controller-manager-k8s-master 1/1 Running 0 6d21h
kube-system kube-proxy-hntmd 1/1 Running 0 6d21h
kube-system kube-proxy-nsl59 1/1 Running 0 6d21h
kube-system kube-proxy-xf49d 1/1 Running 0 6d21h
kube-system kube-scheduler-k8s-master 1/1 Running 0 6d21h
kube-system metrics-server-5f4b65c947-j9qzg 1/1 Running 0 59m