3
1

More than 1 year has passed since last update.

【EKS】「0/1 nodes are available: 1 Too many pods.」の対処法

Last updated at Posted at 2021-12-19

参考

EKS/eksctlについてとても参考になった動画
https://youtu.be/p6xDCz00TxU


エラーが発生した状況

・EKSクラスタをeksctlで構築

eksctl create cluster
 --name test-cluster
 --region ap-northeast-1
 --nodegroup-name linux-nodes
 --node-type t2.micro
 --nodes 1

・NginxのPodを構築したところ、表題のエラーログが表示される。

hoge@nogenoMacBook-Air k8s practice % kubectl get pod                                       
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-66b6c48dd5-xc9dm   0/1     Pending   0          2m35s

hoge@nogenoMacBook-Air k8s practice % kubectl describe pod nginx-deployment-66b6c48dd5-xc9dm
Events:
  Type     Reason            Age                 From               Message
  ----     ------            ----                ----               -------
  Warning  FailedScheduling  3s (x4 over 2m30s)  default-scheduler  0/1 nodes are available: 1 Too many pods.

原因「Podに割り当てるIPアドレスが枯渇している」

・EKSクラスタ内におけるNodeの正体は「EC2インスタンス」である。
・EC2インスタンス(Node)内に構築される各PodにIPアドレスが割り当てられる。
Podに割り当てられるIPアドレス=EC2のセカンダリIP である。
・EC2に設定できるセカンダリIPの数には上限があり、インスタンスタイプがしょぼいほど数は小さい。

*イメージ
スクリーンショット 2021-12-20 1.39.18.png


対処方法

・Node(EC2)の数を増やしてやればいい = 新規追加したEC2のセカンダリIPを利用できる

・Nodeの数/最小数/最大数はNodeGroupで設定されている

*コンソール画面からNodeGroupの設定変更
スクリーンショット 2021-12-20 2.13.32.png
スクリーンショット 2021-12-20 2.15.28.png

・NodeGroupの変更適用後、PodにIPアドレスが割り振られ正常起動したことを確認。

hoge@nogenoMacBook-Air k8s practice % kubectl get pod                                       
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-66b6c48dd5-xc9dm   1/1     Running   0          13m

hoge@nogenoMacBook-Air k8s practice % kubectl describe pod nginx-deployment-66b6c48dd5-xc9dm

Events:
  Type     Reason            Age                   From               Message
  ----     ------            ----                  ----               -------
  Warning  FailedScheduling  2m15s (x13 over 13m)  default-scheduler  0/1 nodes are available: 1 Too many pods.
  Warning  FailedScheduling  78s (x3 over 118s)    default-scheduler  0/2 nodes are available: 1 Too many pods, 1 node(s) had taint {node.kubernetes.io/not-ready: }, that the pod didn't tolerate.
  Normal   Scheduled         67s                   default-scheduler  Successfully assigned default/nginx-deployment-66b6c48dd5-xc9dm to ip-192-168-85-58.ap-northeast-1.compute.internal
  Normal   Pulling           66s                   kubelet            Pulling image "nginx:1.14.2"
  Normal   Pulled            58s                   kubelet            Successfully pulled image "nginx:1.14.2" in 7.467240714s
  Normal   Created           58s                   kubelet            Created container nginx
  Normal   Started           58s                   kubelet            Started container nginx

*セカンダリIPとは?

・EC2(ENI)に設定できるIPアドレスは「プライマリIP」と「セカンダリIP」が存在する。

※下記画像の通り、EC2インスタンス作成時にネットワークインタフェース(ENI)を選択できる。
 このENIに割り当てる「プライマリIP」と「セカンダリIP」を設定できる。
  × IPアドレスはEC2で設定されている
  ○ IPアドレスはEC2にアタッチされているENIで設定されている
スクリーンショット 2021-12-20 1.20.41.png

3
1
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
3
1