List all the running container in whole cluster?

8/2/2019

I want to know how I can check how many containers are currently running in my cluster? is there any command which shows me all the running containers in the cluster, not in a specific namespace. and how I can get the info about how many container per day get's run in my whole cluster?

-- Dashrath Mundkar
kubernetes
kubernetes-pod
openshift

3 Answers

8/2/2019

You need to sum up all running containers in all pods. Try the following command.

kubectl get pod --all-namespaces | awk '{print $3}' | awk -F/ '{s+=$1} END {print s}'
-- Hang Du
Source: StackOverflow

8/2/2019

Get all pods from all namespace :

kubectl get po --all-namespaces

Then you can have the number of containers in the READY column.
You can find some more info in the official doc

-- Marc ABOUCHACRA
Source: StackOverflow

8/2/2019

You can get pods by nodes and phase:

kubectl get po --all-namespaces=true --no-headers -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name,STATUS:.status.phase --sort-by='.metadata.name'

hope this helps

-- paulogrell
Source: StackOverflow