0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PodがImageInspectErrorになる

Posted at

概要

KubernetesでPodを作成する際に、STATUSImageInspectErrorとなりRunningにならない事象が発生したため、その原因と解決方法を調査しました。

バージョン

  • Kubernetes:1.34.1 (Oracle Container Engine for Kubernetes(OKE))
  • CRI-O:1.34.0

事象

Kubernetes公式ドキュメントに掲載されているサンプルアプリケーションのdeployment.yamlを適用したところ、PodのSTATUSImageInspectErrorとなり、正常に起動しませんでした。

$ wget https://k8s.io/examples/application/deployment.yaml
$ kubectl apply -f deployment.yaml
$ kubectl get pods
NAME                               READY   STATUS              RESTARTS   AGE
nginx-deployment-bf744486c-l952b   0/1     ImageInspectError   0          15s
nginx-deployment-bf744486c-lsmwg   0/1     ImageInspectError   0          15s

deployment.yamlは以下の内容です。

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

原因

kubectl describeでPodの詳細情報を確認します。

$ kubectl describe pod nginx-deployment-bf744486c-lsmwg
Name:             nginx-deployment-bf744486c-lsmwg
Namespace:        default
Priority:         0
Service Account:  default
Node:             10.0.10.85/10.0.10.85
Start Time:       Thu, 16 Oct 2025 15:36:22 +0000
Labels:           app=nginx
                  pod-template-hash=bf744486c
Annotations:      <none>
Status:           Pending
IP:               10.0.10.101
IPs:
  IP:           10.0.10.101
Controlled By:  ReplicaSet/nginx-deployment-bf744486c
Containers:
  nginx:
    Container ID:   
    Image:          nginx:1.14.2
    Image ID:       
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImageInspectError
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-g7d8c (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       False 
  ContainersReady             False 
  PodScheduled                True 
Volumes:
  kube-api-access-g7d8c:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason         Age                     From               Message
  ----     ------         ----                    ----               -------
  Normal   Scheduled      9m49s                   default-scheduler  Successfully assigned default/nginx-deployment-bf744486c-lsmwg to 10.0.10.85
  Warning  Failed         7m33s (x12 over 9m47s)  kubelet            Error: ImageInspectError
  Warning  InspectFailed  4m39s (x25 over 9m47s)  kubelet            Failed to inspect image "": rpc error: code = Unknown desc = short name mode is enforcing, but image name nginx:1.14.2 returns ambiguous list

最後に表示されているEvents:の部分を見ると、short name mode is enforcing, but image name nginx:1.14.2 returns ambiguous listというエラーが発生しています。

このエラーを調査したところ、nginx:1.14.2のイメージが レジストリ名を省略した書き方(shortname) になっていることが原因でした。

コンテナランタイムであるCRI-O 1.34.0においてデフォルトで完全修飾イメージ名(レジストリ名/イメージ名:タグ)の指定が必須になっており、レジストリ名を省略するとどのレジストリからイメージを取得すべきか判断できずにImageInspectErrorとなってしまうようです。

Enable shortname enforcement, requiring shortnames to be unambiguous if there are multiple entries that could be pulled from the list of 'unqualified-search-registries'. Generally, users should not enable 'unqualified-search-registries' but if they must be used, they should be unambiguous

shortname強制を有効にし、複数のエントリが'unqualified-search-registries'リストから取得される場合、shortnameが曖昧でないことを要求します。一般的に、ユーザーは'unqualified-search-registries'を有効にすべきではありませんが、どうしても使用する場合は、曖昧でないようにすべきです。

解決方法

deployment.yaml内のnginx:1.14.2を完全修飾イメージ名(レジストリ名/イメージ名:タグ)に修正します。

deployment.yaml(修正)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: docker.io/nginx:1.14.2 #修正
        ports:
        - containerPort: 80

修正後、再度適用します。

$ kubectl apply -f deployment.yaml
$ kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-75b6b65ddb-7pxxj   1/1     Running   0          22s
nginx-deployment-75b6b65ddb-d6f25   1/1     Running   0          22s

無事Runningになりました。

まとめ

PodのImageInspectErrorの原因と解決方法を調査しました。

  • イメージのレジストリ名が省略されていたことが原因
  • CRI-O 1.34.0では完全修飾イメージ名の指定がデフォルトで必須
  • Podが起動しないときはkubectl describeで詳細を確認する

お読みいただきありがとうございました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?