Amazon EKS의 포드 상태 ErrImagePull 및 ImagePullBackoff 오류 문제를 해결하려면 어떻게 해야 합니까?

6분 분량
0

내 Amazon Elastic Kubernetes Service(Amazon EKS) 포드 상태는 ErrImagePull 또는 ImagePullBackoff 상태입니다.

간략한 설명

kubectl 명령 get pods를 실행하는데 포드가 ImagePullBackOff 상태인 경우 포드가 제대로 실행되지 않는 것입니다. ImagePullBackOff 상태는 이미지를 검색하거나 가져올 수 없어서 컨테이너를 시작할 수 없음을 의미합니다. 자세한 내용은 Amazon EKS 커넥터 포드가 ImagePullBackOff 상태 섹션을 참조하세요.

다음과 같은 경우 ImagePull 오류가 발생할 수 있습니다.

  • 이미지 이름, 태그 또는 다이제스트가 올바르지 않습니다.
  • 이미지를 인증하려면 자격 증명이 필요합니다.
  • 레지스트리에 액세스할 수 없습니다.

해결 방법

1. 포드 상태, 오류 메시지를 확인하고 이미지 이름, 태그 및 SHA가 올바른지 확인합니다.

포드 상태를 가져오려면 kubectl 명령 get pods를 실행합니다.

$ kubectl get pods -n default
NAME                              READY   STATUS             RESTARTS   AGE
nginx-7cdbb5f49f-2p6p2            0/1     ImagePullBackOff   0          86s

포드 오류 메시지의 세부 정보를 보려면 kubectl 명령 describe pod를 실행하세요.

$ kubectl describe pod nginx-7cdbb5f49f-2p6p2

...
Events:
  Type     Reason     Age                   From               Message
  ----     ------     ----                  ----               -------
  Normal   Scheduled  4m23s                 default-scheduler  Successfully assigned default/nginx-7cdbb5f49f-2p6p2 to ip-192-168-149-143.us-east-2.compute.internal
  Normal   Pulling    2m44s (x4 over 4m9s)  kubelet            Pulling image "nginxx:latest"
  Warning  Failed     2m43s (x4 over 4m9s)  kubelet            Failed to pull image "nginxx:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for nginxx, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
  Warning  Failed     2m43s (x4 over 4m9s)  kubelet            Error: ErrImagePull
  Warning  Failed     2m32s (x6 over 4m8s)  kubelet            Error: ImagePullBackOff
  Normal   BackOff    2m17s (x7 over 4m8s)  kubelet            Back-off pulling image "nginxx:latest"

$ kubectl describe pod nginx-55d75d5f56-qrqmp ... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 2m20s default-scheduler Successfully assigned default/nginx-55d75d5f56-qrqmp to ip-192-168-149-143.us-east-2.compute.internal Normal Pulling 40s (x4 over 2m6s) kubelet Pulling image "nginx:latestttt" Warning Failed 39s (x4 over 2m5s) kubelet Failed to pull image "nginx:latestttt": rpc error: code = Unknown desc = Error response from daemon: manifest for nginx:latestttt not found: manifest unknown: manifest unknown Warning Failed 39s (x4 over 2m5s) kubelet Error: ErrImagePull Warning Failed 26s (x6 over 2m5s) kubelet Error: ImagePullBackOff Normal BackOff 11s (x7 over 2m5s) kubelet Back-off pulling image "nginx:latestttt" 이미지 태그와 이름이 존재하고 올바른지 확인합니다. 이미지 레지스트리에 인증이 필요한 경우 이미지 레지스트리에 액세스할 수 있는 권한이 있는지 확인합니다. 포드에 사용된 이미지가 올바른지 확인하려면 다음 명령을 실행합니다.

$ kubectl get pods nginx-7cdbb5f49f-2p6p2  -o jsonpath="{.spec.containers[*].image}" | \sort

nginxx:latest

포드 상태 값을 이해하려면 Kubernetes 웹 사이트의 포드 단계를 참조하세요.

자세한 내용은 Amazon EKS에서 포드 상태 문제를 해결하려면 어떻게 해야 합니까?를 참조하세요.

2. Amazon Elastic Container Registry(Amazon ECR) 이미지

Amazon EKS를 사용하여 Amazon ECR에서 이미지를 가져오려는 경우 추가 구성이 필요할 수 있습니다. 이미지가 Amazon ECR 프라이빗 레지스트리에 저장되어 있는 경우 포드에 imagePullSecrets 자격 증명을 지정해야 합니다. 이러한 자격 증명은 프라이빗 레지스트리로 인증하는 데 사용됩니다.

regcred라는 이름의 보안 정보를 생성합니다.

kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

다음 자격 증명을 바꿔야 합니다.

  • <your-registry-server>는 프라이빗 Docker 레지스트리 FQDN입니다. DockerHub에는 https://index.docker.io/v1/을 사용합니다.
  • <your-name>은 Docker 사용자 이름입니다.
  • <your-pword>는 Docker 암호입니다.
  • <your-email>은 Docker 이메일입니다.

클러스터의 Docker 자격 증명을 regcred라는 이름의 보안 정보로 성공적으로 설정했습니다.

regcred 보안 정보의 내용을 이해하려면 보안 정보를 YAML 형식으로 확인하세요.

kubectl get secret regcred --output=yaml

다음 예제에서 포드는 regcred의 Docker 자격 증명에 액세스할 수 있어야 합니다.

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: <your-private-image>
  imagePullSecrets:
  - name: regcred

your.private.registry.example을 다음과 비슷한 프라이빗 레지스트리의 이미지 경로로 바꿉니다.

your.private.registry.example.com/bob/bob-private:v1

프라이빗 레지스트리에서 이미지를 가져오려면 Kubernetes에 자격 증명이 필요합니다. 구성 파일의 imagePullSecrets 필드는 Kubernete가 regcred라는 이름의 보안 정보에서 자격 증명을 가져와야 한다고 명시합니다.

보안 정보 생성에 대한 추가 옵션은 보안 정보를 사용하여 Kubernetes 웹 사이트의 이미지를 가져오는 포드 생성 섹션을 참조하세요.

3. 레지스트리 문제 해결

다음 예제에서는 kubelet이 프라이빗 레지스트리 엔드포인트에 도달할 수 없기 때문에 네트워크 연결 문제로 인해 레지스트리에 액세스할 수 없습니다.

$ kubectl describe pods nginx-9cc69448d-vgm4m

...
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  16m                default-scheduler  Successfully assigned default/nginx-9cc69448d-vgm4m to ip-192-168-149-143.us-east-2.compute.internal
  Normal   Pulling    15m (x3 over 16m)  kubelet            Pulling image "nginx:stable"
  Warning  Failed     15m (x3 over 16m)  kubelet            Failed to pull image "nginx:stable": rpc error: code = Unknown desc = Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
  Warning  Failed     15m (x3 over 16m)  kubelet            Error: ErrImagePull
  Normal   BackOff    14m (x4 over 16m)  kubelet            Back-off pulling image "nginx:stable"
  Warning  Failed     14m (x4 over 16m)  kubelet            Error: ImagePullBackOff

오류 “이미지를 가져오지 못했습니다...“는 kubelet이 Docker 레지스트리 엔드포인트에 연결을 시도했지만 연결 시간 초과로 인해 실패했음을 의미합니다.

이 오류를 해결하려면 지정된 레지스트리 엔드포인트와 통신할 수 있는 서브넷, 보안 그룹 및 네트워크 ACL을 확인하세요.

다음 예제에서는 레지스트리 속도 제한이 초과되었습니다.

$ kubectl describe pod nginx-6bf9f7cf5d-22q48

...
Events:
  Type     Reason                  Age                   From               Message
  ----     ------                  ----                  ----               -------
  Normal   Scheduled               3m54s                 default-scheduler  Successfully assigned default/nginx-6bf9f7cf5d-22q48 to ip-192-168-153-54.us-east-2.compute.internal
  Warning  FailedCreatePodSandBox  3m33s                 kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "82065dea585e8428eaf9df89936653b5ef12b53bef7f83baddb22edc59cd562a" network for pod "nginx-6bf9f7cf5d-22q48": networkPlugin cni failed to set up pod "nginx-6bf9f7cf5d-22q48_default" network: add cmd: failed to assign an IP address to container
  Warning  FailedCreatePodSandBox  2m53s                 kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "20f2e27ba6d813ffc754a12a1444aa20d552cc9d665f4fe5506b02a4fb53db36" network for pod "nginx-6bf9f7cf5d-22q48": networkPlugin cni failed to set up pod "nginx-6bf9f7cf5d-22q48_default" network: add cmd: failed to assign an IP address to container
  Warning  FailedCreatePodSandBox  2m35s                 kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "d9b7e98187e84fed907ff882279bf16223bf5ed0176b03dff3b860ca9a7d5e03" network for pod "nginx-6bf9f7cf5d-22q48": networkPlugin cni failed to set up pod "nginx-6bf9f7cf5d-22q48_default" network: add cmd: failed to assign an IP address to container
  Warning  FailedCreatePodSandBox  2m                    kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "c02c8b65d7d49c94aadd396cb57031d6df5e718ab629237cdea63d2185dbbfb0" network for pod "nginx-6bf9f7cf5d-22q48": networkPlugin cni failed to set up pod "nginx-6bf9f7cf5d-22q48_default" network: add cmd: failed to assign an IP address to container
  Normal   SandboxChanged          119s (x4 over 3m13s)  kubelet            Pod sandbox changed, it will be killed and re-created.
  Normal   Pulling                 56s (x3 over 99s)     kubelet            Pulling image "httpd:latest"
  Warning  Failed                  56s (x3 over 99s)     kubelet            Failed to pull image "httpd:latest": rpc error: code = Unknown desc = Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
  Warning  Failed                  56s (x3 over 99s)     kubelet            Error: ErrImagePull
  Normal   BackOff                 43s (x4 over 98s)     kubelet            Back-off pulling image "httpd:latest"
  Warning  Failed                  43s (x4 over 98s)     kubelet            Error: ImagePullBackOff

Docker 레지스트리 속도 제한은 익명 사용의 경우 6시간당 100개의 컨테이너 이미지 요청이고 Docker 계정의 경우 200개입니다. 이러한 제한을 초과하는 이미지 요청은 6시간이 경과할 때까지 액세스가 거부됩니다. 사용량을 관리하고 레지스트리 속도 제한을 이해하려면 Docker 웹 사이트에서 Docker Hub 속도 제한 이해를 참조하세요.


관련 정보

Amazon EKS 문제 해결

Amazon EKS로 Amazon ECR 문제를 어떻게 해결합니까?

Amazon EKS의 보안 모범 사례

AWS 공식
AWS 공식업데이트됨 일 년 전