kubernetes a count of all Pods on a specific node

2023. 11. 7. 16:13Dev/EKS

728x90
반응형
k get no
NAME                                               STATUS   ROLES    AGE    VERSION
ip-10-90-171-141.ap-northeast-2.compute.internal   Ready    <none>   166d   v1.25.7-eks-a59e1f0
ip-10-90-175-17.ap-northeast-2.compute.internal    Ready    <none>   201d   v1.25.7-eks-a59e1f0
ip-10-90-188-119.ap-northeast-2.compute.internal   Ready    <none>   201d   v1.25.7-eks-a59e1f0
ip-10-90-189-196.ap-northeast-2.compute.internal   Ready    <none>   166d   v1.25.7-eks-a59e1f0
ip-10-90-194-17.ap-northeast-2.compute.internal    Ready    <none>   166d   v1.25.7-eks-a59e1f0
ip-10-90-195-227.ap-northeast-2.compute.internal   Ready    <none>   201d   v1.25.7-eks-a59e1f0
k get po -A -o wide --sort-by="{.spec.nodeName}" -A


NAMESPACE            NAME                                                         READY   STATUS    RESTARTS        AGE     IP              NODE                                               NOMINATED NODE   READINESS GATES
kube-system          ebs-csi-node-t4p7w                                           3/3     Running   0               166d    10.90.167.1     ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
kube-system          secrets-store-csi-driver-982rm                               3/3     Running   0               166d    10.90.164.58    ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
prometheus           promtail-prd-8gp46                                           1/1     Running   0               105d    10.90.165.2     ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
prometheus           prometheus-release-prometheus-node-exporter-swg29            1/1     Running   0               166d    10.90.171.141   ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
kube-system          csi-secrets-store-provider-aws-vpmh9                         1/1     Running   0               166d    10.90.171.141   ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
kube-system          aws-node-2j622                                               1/1     Running   0               166d    10.90.171.141   ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
kube-system          kube-proxy-5czr6                                             1/1     Running   0               166d    10.90.171.141   ip-10-90-171-141.ap-northeast-2.compute.internal   <none>           <none>
kube-system          aws-load-balancer-controller-658fb99494-xgp5m                1/1     Running   1 (123d ago)    201d    10.90.170.155   ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           prometheus-release-kube-state-metrics-7875b4478-zpfzn        1/1     Running   0               201d    10.90.173.81    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           prometheus-release-grafana-8d778dc74-cngk4                   3/3     Running   0               201d    10.90.171.8     ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          csi-secrets-store-provider-aws-gv849                         1/1     Running   0               178d    10.90.175.17    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
argocd               argocd-redis-66dbdbddd8-knz85                                1/1     Running   0               201d    10.90.163.59    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          kube-proxy-mqhn9                                             1/1     Running   0               201d    10.90.175.17    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
argocd               argocd-application-controller-0                              1/1     Running   0               201d    10.90.164.49    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           promtail-prd-gtckv                                           1/1     Running   0               105d    10.90.162.146   ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          ebs-csi-node-m4cl9                                           3/3     Running   0               201d    10.90.172.53    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           prometheus-release-prometheus-node-exporter-l44gb            1/1     Running   0               201d    10.90.175.17    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
argocd               argocd-notifications-controller-8cc7b9fc-wwsqd               1/1     Running   0               201d    10.90.163.142   ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
default              testnet                                                      1/1     Running   1 (200d ago)    200d    10.90.166.98    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
ingress-nginx        ingress-nginx-controller-7dcd48cb65-p6d4b                    1/1     Running   0               193d    10.90.175.193   ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          coredns-d9cdf8499-fj6c2                                      1/1     Running   0               201d    10.90.161.86    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          aws-node-vtgwf                                               1/1     Running   0               201d    10.90.175.17    ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          secrets-store-csi-driver-f8rtj                               3/3     Running   0               178d    10.90.162.103   ip-10-90-175-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          ebs-csi-controller-788d947445-knrqw                          6/6     Running   13 (182d ago)   201d    10.90.188.52    ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-server-6b648975b7-vjvmh                               1/1     Running   0               201d    10.90.186.126   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
prometheus           promtail-prd-hfshk                                           1/1     Running   0               105d    10.90.178.163   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
prometheus           prometheus-release-prometheus-node-exporter-q7brr            1/1     Running   0               201d    10.90.188.119   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          aws-node-ntznc                                               1/1     Running   0               201d    10.90.188.119   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          aws-load-balancer-controller-658fb99494-brckh                1/1     Running   3 (182d ago)    201d    10.90.191.233   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-application-controller-1                              1/1     Running   0               201d    10.90.188.145   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
prometheus           alertmanager-prometheus-release-kube-pr-alertmanager-0       2/2     Running   1 (201d ago)    201d    10.90.183.230   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
otel                 opentelemetry-operator-6fcbcc6586-nzvwg                      2/2     Running   0               96d     10.90.191.84    ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
default              psg                                                          1/1     Running   1 (200d ago)    200d    10.90.181.12    ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          csi-secrets-store-provider-aws-j55b7                         1/1     Running   0               178d    10.90.188.119   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          secrets-store-csi-driver-hmr87                               3/3     Running   0               178d    10.90.187.226   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-applicationset-controller-7d5477878-tgkrl             1/1     Running   0               201d    10.90.187.217   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
cluster-autoscaler   cluster-autoscaler-aws-cluster-autoscaler-84b467d44d-xmxj2   1/1     Running   0               175d    10.90.184.165   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          kube-proxy-nrgxr                                             1/1     Running   0               201d    10.90.188.119   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-repo-server-76f9bd85b-fk69z                           1/1     Running   0               201d    10.90.179.111   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          ebs-csi-node-6p455                                           3/3     Running   0               201d    10.90.185.175   ip-10-90-188-119.ap-northeast-2.compute.internal   <none>           <none>
kube-system          kube-proxy-ss4xd                                             1/1     Running   0               166d    10.90.189.196   ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
kube-system          ebs-csi-node-jl5wf                                           3/3     Running   0               166d    10.90.190.208   ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
prometheus           promtail-prd-flrkr                                           1/1     Running   0               105d    10.90.183.61    ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
prometheus           prometheus-release-prometheus-node-exporter-t8sjf            1/1     Running   0               166d    10.90.189.196   ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
kube-system          secrets-store-csi-driver-tm4fk                               3/3     Running   0               166d    10.90.181.38    ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
kube-system          csi-secrets-store-provider-aws-plk6g                         1/1     Running   0               166d    10.90.189.196   ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
kube-system          aws-node-4dkbc                                               1/1     Running   0               166d    10.90.189.196   ip-10-90-189-196.ap-northeast-2.compute.internal   <none>           <none>
kube-system          kube-proxy-nkrx7                                             1/1     Running   0               166d    10.90.194.17    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          csi-secrets-store-provider-aws-nf8mw                         1/1     Running   0               166d    10.90.194.17    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          secrets-store-csi-driver-k7kwf                               3/3     Running   0               166d    10.90.207.18    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          aws-node-fgsgn                                               1/1     Running   0               166d    10.90.194.17    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           promtail-prd-bmdtc                                           1/1     Running   0               105d    10.90.192.187   ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
otel                 acp-collector-collector-6f988986d8-wbb4s                     1/1     Running   0               63d     10.90.200.95    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           prometheus-release-prometheus-node-exporter-x97lb            1/1     Running   0               166d    10.90.194.17    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
kube-system          ebs-csi-node-hthwk                                           3/3     Running   0               166d    10.90.194.52    ip-10-90-194-17.ap-northeast-2.compute.internal    <none>           <none>
prometheus           prometheus-release-kube-pr-operator-7f9674f98f-djcf6         1/1     Running   0               201d    10.90.194.49    ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
ingress-nginx        ingress-nginx-controller-7dcd48cb65-zcpd9                    1/1     Running   0               193d    10.90.203.154   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-dex-server-6556b7fb5c-sx8l9                           1/1     Running   0               201d    10.90.206.67    ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
prometheus           prometheus-prometheus-release-kube-pr-prometheus-0           2/2     Running   0               201d    10.90.203.166   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          kube-proxy-h2ngc                                             1/1     Running   0               201d    10.90.195.227   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
prometheus           prometheus-release-prometheus-node-exporter-nzp9m            1/1     Running   0               201d    10.90.195.227   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          aws-node-g7sqv                                               1/1     Running   0               201d    10.90.195.227   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          coredns-d9cdf8499-7gzhl                                      1/1     Running   0               201d    10.90.207.253   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-repo-server-76f9bd85b-ttn69                           1/1     Running   0               201d    10.90.199.103   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          csi-secrets-store-provider-aws-2crpg                         1/1     Running   0               178d    10.90.195.227   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
argocd               argocd-server-6b648975b7-kmnkk                               1/1     Running   1 (139d ago)    201d    10.90.197.22    ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
metrics-server       metrics-server-7fb77694bd-kbz78                              1/1     Running   0               166d    10.90.192.177   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          ebs-csi-node-gphmj                                           3/3     Running   0               201d    10.90.203.88    ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          ebs-csi-controller-788d947445-zdhhn                          6/6     Running   13 (182d ago)   201d    10.90.196.130   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kube-system          secrets-store-csi-driver-lwtft                               3/3     Running   0               178d    10.90.207.220   ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
prometheus           promtail-prd-jpdks                                           1/1     Running   0               105d    10.90.194.79    ip-10-90-195-227.ap-northeast-2.compute.internal   <none>           <none>
kubectl get pods -o custom-columns="NODE:.spec.nodeName" -A | tail -n +2 | awk '{node[$1]++} END {for (n in node) print "Node "n"에 해당하는 행(row) 개수: "node[n]"개입니다."}'

Node ip-10-90-188-119.ap-northeast-2.compute.internal에 해당하는 행(row) 개수: 17개입니다.
Node ip-10-90-189-196.ap-northeast-2.compute.internal에 해당하는 행(row) 개수: 11개입니다.
Node ip-10-90-171-141.ap-northeast-2.compute.internal에 해당하는 행(row) 개수: 11개입니다.
Node ip-10-90-175-17.ap-northeast-2.compute.internal에 해당하는 행(row) 개수: 16개입니다.
Node ip-10-90-195-227.ap-northeast-2.compute.internal에 해당하는 행(row) 개수: 16개입니다.
Node ip-10-90-194-17.ap-northeast-2.compute.internal에 해당하는 행(row) 개수: 10개입니다.
k get po -A --field-selector spec.nodeName=ip-10-90-195-227.ap-northeast-2.compute.internal
NAMESPACE        NAME                                                   READY   STATUS    RESTARTS        AGE
argocd           argocd-dex-server-6556b7fb5c-sx8l9                     1/1     Running   0               201d
argocd           argocd-repo-server-76f9bd85b-ttn69                     1/1     Running   0               201d
argocd           argocd-server-6b648975b7-kmnkk                         1/1     Running   1 (139d ago)    201d
ingress-nginx    ingress-nginx-controller-7dcd48cb65-zcpd9              1/1     Running   0               193d
kube-system      aws-node-g7sqv                                         1/1     Running   0               201d
kube-system      coredns-d9cdf8499-7gzhl                                1/1     Running   0               201d
kube-system      csi-secrets-store-provider-aws-2crpg                   1/1     Running   0               178d
kube-system      ebs-csi-controller-788d947445-zdhhn                    6/6     Running   13 (182d ago)   201d
kube-system      ebs-csi-node-gphmj                                     3/3     Running   0               201d
kube-system      kube-proxy-h2ngc                                       1/1     Running   0               201d
kube-system      secrets-store-csi-driver-lwtft                         3/3     Running   0               178d
metrics-server   metrics-server-7fb77694bd-kbz78                        1/1     Running   0               166d
prometheus       prometheus-prometheus-release-kube-pr-prometheus-0     2/2     Running   0               201d
prometheus       prometheus-release-kube-pr-operator-7f9674f98f-djcf6   1/1     Running   0               201d
prometheus       prometheus-release-prometheus-node-exporter-nzp9m      1/1     Running   0               201d
prometheus       promtail-prd-jpdks                                     1/1     Running   0               105d

 

sort나 custom-columns를 이용한 방법은 검색이 잘 안되서 글로 남깁니다.

chatGPT도 한방에는 잘 안알려주고 디버깅하고 계속 질문하니까 알려주네요.