K8S 查询节点上运行的 Pod

# kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=10.0.0.15
NAMESPACE          NAME                                              READY   STATUS    RESTARTS   AGE     IP            NODE        NOMINATED NODE   READINESS GATES
default            dashboard-kubernetes-dashboard-6dd7944c6b-6bx6t   2/2     Running   1          4d16h   172.16.2.6    10.0.0.15   <none>           <none>
default            kibana-kibana-7cbc5db55c-22n24                    1/2     Running   0          4d16h   172.16.2.7    10.0.0.15   <none>           <none>
default            metricbeat-kube-state-metrics-885954bb6-lgs6v     2/2     Running   1          4d16h   172.16.2.9    10.0.0.15   <none>           <none>
default            metricbeat-metricbeat-mn7lt                       1/2     Running   2          4d16h   172.16.2.2    10.0.0.15   <none>           <none>
default            nfs-provisioner-68c8cf6bbf-dxb4d                  2/2     Running   1          4d16h   172.16.2.8    10.0.0.15   <none>           <none>
default            productpage-v1-7658b8dcc6-j2gqk                   2/2     Running   0          4d16h   172.16.2.5    10.0.0.15   <none>           <none>
default            ratings-v1-84975bc778-srp98                       2/2     Running   0          4d16h   172.16.2.10   10.0.0.15   <none>           <none>
default            reviews-v1-5787f7b87-cq9w9                        2/2     Running   0          4d16h   172.16.2.11   10.0.0.15   <none>           <none>
istio-system       istio-egressgateway-848f9d68b8-hcrf8              1/1     Running   0          4d15h   172.16.2.15   10.0.0.15   <none>           <none>
istio-system       istio-galley-698fb8c979-nqtzx                     1/1     Running   0          4d15h   172.16.2.16   10.0.0.15   <none>           <none>
istio-system       istio-policy-7c65fc9c75-66t8p                     2/2     Running   0          4d15h   172.16.2.14   10.0.0.15   <none>           <none>
kube-system        ccs-log-collector-2xpmg                           1/1     Running   0          12m     10.0.0.15     10.0.0.15   <none>           <none>
kube-system        ip-masq-agent-scc8h                               1/1     Running   0          4d16h   10.0.0.15     10.0.0.15   <none>           <none>
kube-system        l7-lb-controller-57c49c745d-g5k9d                 1/1     Running   0          4d16h   172.16.2.4    10.0.0.15   <none>           <none>
kube-system        swift-6d58f67657-854fz                            2/2     Running   0          4d16h   172.16.2.3    10.0.0.15   <none>           <none>
ops                query-ip-0-20-bb5595b5c-2g9qn                     2/2     Running   0          4d15h   172.16.2.13   10.0.0.15   <none>           <none>
tekton-pipelines   tekton-pipelines-controller-5f5585ff7f-pj92f      1/1     Running   0          3d21h   172.16.2.19   10.0.0.15   <none>           <none>
tekton-pipelines   tekton-pipelines-webhook-5d8c686cb6-97hjt         1/1     Running   0          3d21h   172.16.2.20   10.0.0.15   <none>           <none>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  • 按节点排序展示 Pod

默认为 default namespace

# kubectl get pods -o wide --sort-by="{.spec.nodeName}"
NAME                                              READY   STATUS    RESTARTS   AGE     IP             NODE        NOMINATED NODE   READINESS GATES
metricbeat-metricbeat-b5269                       1/2     Running   2          17d     172.16.7.129   10.0.0.6    <none>           <none>
metricbeat-kube-state-metrics-885954bb6-lgs6v     2/2     Running   1          4d16h   172.16.2.9     10.0.0.15   <none>           <none>
dashboard-kubernetes-dashboard-6dd7944c6b-6bx6t   2/2     Running   1          4d16h   172.16.2.6     10.0.0.15   <none>           <none>
reviews-v1-5787f7b87-cq9w9                        2/2     Running   0          4d16h   172.16.2.11    10.0.0.15   <none>           <none>
metricbeat-metricbeat-mn7lt                       1/2     Running   2          4d16h   172.16.2.2     10.0.0.15   <none>           <none>
ratings-v1-84975bc778-srp98                       2/2     Running   0          4d16h   172.16.2.10    10.0.0.15   <none>           <none>
kibana-kibana-7cbc5db55c-22n24                    1/2     Running   0          4d16h   172.16.2.7     10.0.0.15   <none>           <none>
productpage-v1-7658b8dcc6-j2gqk                   2/2     Running   0          4d16h   172.16.2.5     10.0.0.15   <none>           <none>
nfs-provisioner-68c8cf6bbf-dxb4d                  2/2     Running   1          4d16h   172.16.2.8     10.0.0.15   <none>           <none>
query-ip-574b8bf54c-4r5d2                         2/2     Running   0          4d15h   172.16.4.9     10.0.0.16   <none>           <none>
heartbeat-5fdf464d4d-kzl4g                        2/2     Running   0          4d15h   172.16.4.10    10.0.0.16   <none>           <none>
gitbbook-c5f9c7bb5-lngkx                          2/2     Running   0          3d8h    172.16.4.23    10.0.0.16   <none>           <none>
metricbeat-metricbeat-tfvqv                       1/2     Running   2          4d15h   172.16.4.2     10.0.0.16   <none>           <none>
reviews-v3-7d5549f9-nxvz7                         1/2     Running   0          4d15h   172.16.4.6     10.0.0.16   <none>           <none>
print-header-7c9859b94c-pbjsr                     2/2     Running   0          4d15h   172.16.3.9     10.0.0.19   <none>           <none>
metricbeat-metricbeat-676rg                       1/2     Running   1          4d16h   172.16.3.2     10.0.0.19   <none>           <none>
grafana-599dcff7f4-d2gjv                          2/2     Running   0          4d15h   172.16.3.8     10.0.0.19   <none>           <none>
details-v1-6978996b-jn5fm                         2/2     Running   0          4d15h   172.16.3.5     10.0.0.19   <none>           <none>
reviews-v2-6d8b975647-7gbvb                       2/2     Running   0          4d15h   172.16.3.6     10.0.0.19   <none>           <none>
apm-server-7-84cd8f97c7-qw9xr                     2/2     Running   0          4d15h   172.16.3.10    10.0.0.19   <none>           <none>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

reference