MeWrite Docs

Pod stuck in Pending state

KubernetesでPodがPending状態から進まない場合の解決方法

概要

Podが Pending 状態で停止する問題は、Kubernetesがスケジューラによってノードにスケジュールできない場合に発生します。リソース不足、ノードセレクタの不一致、PersistentVolumeの問題などが原因です。

エラーメッセージ

NAME        READY   STATUS    RESTARTS   AGE
my-pod      0/1     Pending   0          5m
1
2
3
4
5
# kubectl describe pod my-pod
Events:
  Warning  FailedScheduling  default-scheduler  0/3 nodes are available:
  1 node(s) had taint {node.kubernetes.io/not-ready: }, that the pod didn't tolerate,
  2 Insufficient cpu, 2 Insufficient memory.

原因と解決策

1. リソース不足

1
2
# Events
Warning  FailedScheduling  0/3 nodes are available: 3 Insufficient cpu.

解決策:

1
2
3
4
5
6
7
8
# リソース要求を減らす
spec:
  containers:
    - name: app
      resources:
        requests:
          cpu: "100m"      # 1000mから100mに減らす
          memory: "128Mi"  # 1Giから128Miに減らす
1
2
3
4
# ノードのリソース確認
kubectl describe nodes | grep -A5 "Allocated resources"

# クラスターにノードを追加

2. ノードセレクタの不一致

1
2
# Events
Warning  FailedScheduling  0/3 nodes are available: 3 node(s) didn't match Pod's node affinity/selector.

解決策:

1
2
3
4
5
# ノードのラベル確認
kubectl get nodes --show-labels

# ラベルを追加
kubectl label nodes my-node disktype=ssd
1
2
3
4
# またはnodeSelectorを削除/修正
spec:
  nodeSelector:
    disktype: ssd  # このラベルを持つノードが必要

3. Taintに対するTolerationがない

1
2
# Events
Warning  FailedScheduling  0/3 nodes are available: 3 node(s) had taint {gpu: true}, that the pod didn't tolerate.

解決策:

1
2
3
4
5
6
spec:
  tolerations:
    - key: "gpu"
      operator: "Equal"
      value: "true"
      effect: "NoSchedule"

4. PersistentVolumeClaimがBoundでない

1
2
# Events
Warning  FailedScheduling  persistentvolumeclaim "my-pvc" not found

解決策:

1
2
3
4
5
# PVCの状態確認
kubectl get pvc

# PVが利用可能か確認
kubectl get pv
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# PVCを作成
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

5. リソースクォータ超過

1
2
3
4
5
# クォータ確認
kubectl describe resourcequota

# 使用量確認
kubectl get resourcequota -o yaml

デバッグ手順

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 1. Podの詳細確認
kubectl describe pod my-pod

# 2. Eventsを確認
kubectl get events --sort-by=.metadata.creationTimestamp

# 3. ノードの状態確認
kubectl get nodes
kubectl describe node <node-name>

# 4. スケジューラのログ
kubectl logs -n kube-system -l component=kube-scheduler

関連エラー

関連エラー

Kubernetes の他のエラー

最終更新: 2025-12-17