Unable to connect to the server / Kubernetes cluster unreachable

트러블 슈팅
문제 상황
문제 원인
해결 방법
결과
문제 상황
커멘드
kubectl get pods에러 유형 1
E0429 15:39:11.365619 9560 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it. E0429 15:39:11.376349 9560 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it. E0429 15:39:11.378040 9560 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it. E0429 15:39:11.379120 9560 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it. E0429 15:39:11.380299 9560 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it. Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.에러 유형 2
Kubernetes cluster unreachable
문제 원인
쿠버네티스 클러스터 연결 부분에 문제가 있는 것 같습니다.
사용자 경로에 .kube/config 파일이 없습니다.
kubectl config view --flatten으로 확인한 결과 다음과 같은 config 파일이 보입니다. 즉 KUBECONFIG은 존재하지만, 클러스터가 null로 입력되어 있습니다.apiVersion: v1 clusters: null contexts: null current-context: "" kind: Config preferences: {} users: nullwhere kubectl로 확인하면 kubectl은 도커 하위에 존재하는 것을 알 수 있었습니다. 언젠가 도커를 설치하면서 같이 딸려온 것 같습니다.→
choco install kubectl로 재설치 진행했습니다.
쿠버네티스 클러스터를 활성화하고 연결만 하면 될 것 같습니다.
해결 방법
현재 시스템에서 쓰고 있는 쿠버네티스 파일이 Docker 내부에 있는 kubectl인 것을 확인했습니다.
따라서 Docker Desktop for Windows 내부에 해당 기능이 있을 것으로 예상했습니다.
관련해서 Stackoverflow (QnA) | Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it를 참고해서 Kubernetes를 활성화 해주었습니다.
클러스터 활성화 시작
클러스터 활성화 완료
테스트하기
문제가 된 구문들
kubectl get pods를 재입력해보면 정상적으로
No resources found in default namespace라는 내용이 반환됩니다.kubectl get podsKUBECONFIG
null로 나오던 부분들에 특정한 값들이 들어가 있습니다.
자세한 내용은 생략하겠습니다.kubectl config view
결과
해결되었습니다.