728x90
docker desktop 에서 rancher로 변경후 kubectl 명령어를 실행시 오류바 발생했다.
~ kubectl version
Client Version: v1.34.0
Kustomize Version: v5.7.1
Unable to connect to the server: tls: failed to verify certificate: x509: certificate signed by unknown authority
➜ ~ kubectl get nodes
Unable to connect to the server: tls: failed to verify certificate: x509: certificate signed by unknown authority
인증서가 잘못되었다. 즉 신뢰 할수 없다는 경고문이 떳고 ? 인테넷을 검색해보니 여러가지 경우가 존재했다.
나의 경우는 Rancher UI에 접속해보니 이런 알림이 존재했다.

kubenetes의 컨텍스트를 rancher-desktop이 아니라 docker-desktop을 사용한다는 알림이었다. rancher-desktop을 사용중인데 docker-desktop이라니?
gpt의 힘을빌려 해당 경고에 대한 검색을 했고, context에 대해 조사해보라고 팁을 주어 확인해보았다.
➜ ~ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* docker-desktop docker-desktop docker-desktop
rancher-desktop rancher-desktop rancher-desktop
두개의 컨텍스트가 있고 현재 선택된건 docker-desktop이라 다음명령어를 사용하여 rancher-desktop으로 변경하였다.
➜ ~ kubectl config use-context rancher-desktop
Switched to context "rancher-desktop".
이후 정상적으로 동작되는 걸 확인 할 수 있었다.
➜ ~ kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:6443
CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/https:metrics-server:https/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
➜ ~ kubectl get nodes
NAME STATUS ROLES AGE VERSION
lima-rancher-desktop Ready control-plane,master 32d v1.33.4+k3s1
문제원인
- Mac에 Rancher desktop과 docker desktop 둘다 설치되어 있음
- 기본 context가 docker desktop으로 설정되어있음
- reacher desktop 클러스터 인증서를 사용하지 않음으로 TLS 오류 발생
해결 방법
- kubectl 로 context 변경
'devops > docker' 카테고리의 다른 글
| docker env, arg 차이점 (1) | 2024.04.07 |
|---|---|
| dockerfile에 springboot profile 적용하기 (1) | 2024.04.07 |
| 도커 실행 권한문제 - dial unix /var/run/docker.sock: connect: permission denied (0) | 2023.04.17 |
| docker-compose mysql 설정 및 sql init (0) | 2022.01.14 |
| docker-compose jenkins (0) | 2022.01.14 |