LoginSignup
0

More than 3 years have passed since last update.

kubernetesのkubectl get podでrunningのものだけを取得する

Posted at

Runningだけ取り出すとか
Running以外を取り出すとか色々出来ます。

全pod

$ kubectl get pods
NAME                             READY   STATUS    RESTARTS   AGE
hoge-web-56fb76798d-v27l8   0/2     Evicted   0          13h
hoge-web-56fb76798d-xgf2f   2/2     Running   0          61m

Runningだけ

$ kubectl get pods --field-selector=status.phase=Running
NAME                             READY   STATUS    RESTARTS   AGE
hoge-web-56fb76798d-xgf2f   2/2     Running   0          61m

Running以外

$ kubectl get pods --field-selector=status.phase!=Running
NAME                             READY   STATUS    RESTARTS   AGE
hoge-web-56fb76798d-v27l8   0/2     Evicted   0          13h

pod名だけを取り出す

$ kubectl get pods -o=jsonpath={.items[*].metadata.name} --field-selector=status.phase!=Running

hoge-web-56fb76798d-v27l8

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
What you can do with signing up
0