본문 바로가기
kubenetes

ImagePullBackOff error 해결

by kyeongseo.oh 2022. 4. 2.

error 발생

Events:
  Type     Reason          Age                From               Message
  ----     ------          ----               ----               -------
  Normal   Scheduled       15s                default-scheduler  Successfully assigned default/testdeploy-cff5cf7d9-mws8j to kw1.dd.io
  Normal   Pulling         14s                kubelet            Pulling image "harbor.ks.io/privatetest/flasktest:latest"
  Warning  Failed          14s                kubelet            Failed to pull image "harbor.ks.io/privatetest/flasktest:latest": rpc error: code = Unknown desc = Error response from daemon: unauthorized: unauthorized to access repository: privatetest/flasktest, action: pull: unauthorized to access repository: privatetest/flasktest, action: pull
  Warning  Failed          14s                kubelet            Error: ErrImagePull
  Normal   SandboxChanged  13s                kubelet            Pod sandbox changed, it will be killed and re-created.
  Normal   BackOff         11s (x3 over 12s)  kubelet            Back-off pulling image "harbor.ks.io/privatetest/flasktest:latest"
  Warning  Failed          11s (x3 over 12s)  kubelet            Error: ImagePullBackOff

 

docker login -> 동일 에러 발생

docker login harbor.ks.io

 


시크릿 생성 (from-file에는 절대경로를 적어줘야함)

kubectl create secret generic regcred \
    --from-file=.dockerconfigjson=/root/.docker/config.json \
    --type=kubernetes.io/dockerconfigjson



# 서비스 어카운트가 시크릿을 사용하게 패치

[root@kw1 flasktest]# kubectl get serviceaccount
NAME      SECRETS   AGE
default   1         13d
[root@kw1 flasktest]# kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "regcred"}]}'
serviceaccount/default patched


시크릿 패치 후 확인해보니 잘 동작함

[root@kw1 flasktest]# kubectl create deploy testdeploy --image=harbor.ks.io/privatetest/flasktest:latest
deployment.apps/testdeploy created
[root@kw1 flasktest]# kubectl get pod
NAME                         READY   STATUS    RESTARTS   AGE
testdeploy-cff5cf7d9-qj2xh   1/1     Running   0          5s

 

댓글