Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

kubectl get services with count of actively running pods

How can I list all Kubernetes services along with the number of active pods associated with each service?

Currently, I can list all services with:
kubectl get services

I would like to add one additional column to the output, which lists active pod count for each service.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

A service is basically a load balancer over a deployment (and a deployment is a replica set of multiple pods). So, chances are you want to be listing the deployments instead of the services in this case. Services and deployments are loosely coupled via tags, so there probably isn’t a great way to go from services to pods directly.

I recommend kubectl get deploy -A to view all deployments and their pod counts in all namespaces in this case.

Example output from the kube-system namespace in our cluster (since it’s not sensitive in any way)…

NAMESPACE                        NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
kube-system                      cluster-autoscaler-aws-cluster-autoscaler   1/1     1            1           231d
kube-system                      coredns                                     2/2     2            2           231d
kube-system                      ebs-csi-controller                          2/2     2            2           231d
kube-system                      efs-csi-controller                          2/2     2            2           231d
kube-system                      metrics-server                              1/1     1            1           231d
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading