본문 바로가기
Tech/Containers

[kubernetes]Trouble shooting

by 타이호 2018. 3. 30.
반응형


Trouble Shooting

이전 포스트에서 replica set을 1개에서 3개로 변경하고 이미지를 prod tag가 있는 이미지로 업데이트 후 아래와 같은 에러가 발생하였다. 

배포 후 ErrImagePull 이라는 에러가 나와서 해당 pod의 로그를 살펴본다.

$ kubectl get pods -l 'tier=frontend'

NAME                                READY     STATUS             RESTARTS   AGE

apache-petclinic-54bf9c58cb-5w46p   1/1       Running            0          1d

apache-petclinic-54bf9c58cb-7795t   1/1       Running            0          12m

apache-petclinic-568d9fd7db-64brr   0/1       ErrImagePull       0          6m

apache-petclinic-568d9fd7db-shczx   0/1       ImagePullBackOff   0          6m

kubectl log 명령을 통해 해당 pod의 로그를 살펴본다

$ kubectl logs apache-petclinic-568d9fd7db-64brr

Error from server: Get https://k8s-node-3:10250/containerLogs/default/apache-petclinic-568d9fd7db-64brr/apache-petclinic: dial tcp: lookup k8s-node-3 on 8.8.8.8:53: no such host

node의 hostname을 lookup하지 못해 나온 에러이므로 /etc/hosts에 worker node ip를 설정한다.

172.16.1.14 k8s-node-1

172.16.1.4 k8s-node-2 

172.16.1.17 k8s-node-3

그리고 다시 log를 조회해 본다.

$ kubectl logs apache-petclinic-568d9fd7db-64brr

Error from server (BadRequest): container "apache-petclinic" in pod "apache-petclinic-568d9fd7db-64brr" is waiting to start: image can't be pulled

해당 에러는 prod 태그를 가진 이미지가 docker hub에 없어서 발생된 문제이다. 다시 docker hub에 이미지를 업로드 후 kubernetes가 자동으로 이미지를 반영한다.

 kubectl get pods

NAME                                               READY     STATUS              RESTARTS   AGE

apache-petclinic-54bf9c58cb-5w46p                  1/1       Running             0          2d

apache-petclinic-54bf9c58cb-7795t                  1/1       Terminating         0          1d

apache-petclinic-568d9fd7db-64brr                  1/1       Running             0          23h

apache-petclinic-568d9fd7db-shczx                  0/1       ImagePullBackOff    0          23h

apache-petclinic-568d9fd7db-tfndw                  0/1       ContainerCreating   0          14s


정상적으로 반영되면 아래와 같이 3개의 pod가 Running하는 것을 볼 수 있다.

$ kubectl get pods

NAME                                               READY     STATUS    RESTARTS   AGE

apache-petclinic-568d9fd7db-64brr                  1/1       Running   0          1d

apache-petclinic-568d9fd7db-shczx                  1/1       Running   0          1d

apache-petclinic-568d9fd7db-tfndw                  1/1       Running   0          4m


반응형