2
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?

More than 3 years have passed since last update.

kubectlでNodeGroupにあるPodを一覧表示する(AWS EKS, Kubernetes)

Posted at

NodeGroupごとにPodを一覧表示する

pod_list=$(kubectl get pods -A -o jsonpath='{range .items[*]}{@.spec.nodeName}{"\t"}{@.metadata.name}{"\t"}{@.metadata.namespace}{"\n"}{end}')
sed_cmd=$(kubectl get nodes -o jsonpath='{range .items[*]}sed "s/{@.metadata.name}/{@.metadata.labels.nodegroup-name}/g" | {end}sort')
echo "$pod_list" | eval "$sed_cmd"

任意のNodeGroupのNodeにあるPodを一覧表示する

上のコマンドの後ろに| grep "NodeGroup名"をつけてください

感想

ググっても出なかったのでjsonpathで気合で頑張りました。

もっと良いやり方をご存じの方は何卒コメントでご教授ください。

2
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
2
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?