🌱 Infra/Container_ Kubernetes

[k8s] ERROR - The connection to server was refused

mini_world 2022. 2. 21. 21:40
목차 접기

 

정말 오래간만에 쿠버네티스 공부하는데... 아주 오래간만이라 또 오만가지 오류 시작입니다 🥲.... 삶이란..삶은...달걀이다...

오류를 살펴봅시다.

[root@ip-10-77-110-113 docker]# kubectl run myapp --image=myapp-image --port=8080
The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

이 오류는 저는 이렇게 해결했습니다.

1) kube init 명령어를 사용해서 kubectl 초기 설정을 해봅시다. 애초에 kubectl 명령어는 마스터 노드에서만 사용할 수 있으니까요.!

kubeadm init

2) 설정파일을 옮겨줍시다.

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

 

이제 명령어 잘 되는지 확인해봅시다.

[root@ip-10-77-110-113 docker]# kubectl run myapp --image=myapp-image --port=8081
pod/myapp created

오! 잘 됩니다!1 🥳 
모두 화이팅!!

728x90