If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
A node contains one or more pods, and each pod contains one or more containers.
Before issuing the oc get pods command, issue the oc login command. In this example, project001 does not contain any pods.
~]# oc get pods -n project001
No resources found.
On the other hand, if your selected project contains one or more pods, something like this should be returned.
~]# oc get pods --namespace project001
NAME READY STATUS RESTARTS AGE
foo-9mzm2 1/1 Running 0 8d
foo-vmzmz 1/1 Running 0 8d
bar-pflxc 1/1 Running 0 8d
If you do not want to use the -n or --namespace command line option, you can select a project and then issue the oc get pods command without the -n option.
~]# oc get pods
NAME READY STATUS RESTARTS AGE
foo-9mzm2 1/1 Running 0 8d
foo-vmzmz 1/1 Running 0 8d
bar-pflxc 1/1 Running 0 8d
The -o wide option can be used to include addtional fields.
~]# oc get pods -o wide --namespace project001
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED MODE
foo-9mzm2 1/1 Running 0 8d 10.142.118.51 server1.example.com <none>
foo-vmzmz 1/1 Running 0 8d 10.142.118.52 server2.example.com <none>
bar-pflxc 1/1 Running 0 8d 10.142.118.53 server3.example.com <none>
And here is how to view the pods in a specific node.
~]# oc get pods --all-namespaces --field-selector spec.nodeName=dev001-worker-5n4fj
NAMESPACE NAME READY STATUS RESTARTS AGE
project001 foo-9mzm2 1/1 Running 0 84d
project001 foo-vmzmz 1/1 Running 0 84d
project002 bar-pflxc 1/1 Running 0 84d
The -A o --all-namespaces flag can be used to return every pod in every namespace.
~]# oc get pod001 --all-namespaces
NAMESPACE NAME MANAGEMENT STATE HEALTH NODES DATA NODES SHARD ALLOCATION INDEX MANAGEMENT
project001 foo-9mzm2 Managed green 3 3 all
The -o or --output option and custom-columns can be used to customize the columns that are returned. In this example, only the pod and node names will be returned.
~]$ oc get pods --output custom-columns=POD:.metadata.name,custom-columns=POD:.spec.nodeName
POD NODE
foo-9mzm2 worker-84928
foo-vmzmz worker-pcl22
bar-pflxc worker-8wjg7
The -o json or -o yaml option can be used to show the pods JSON or YAML file.
oc get pod foo-vmzmz -o yaml
If you create a pod and deploy an app using the oc new-app command, something like this should be displayed.
NAME READY STATUS RESTARTS AGE
foo-vmzmz 0/1 Init:0/2 0 15s
If a pod fails to initialize, something like this should be displayed.
NAME READY STATUS RESTARTS AGE
foo-vmzmz 0/1 Init:Error 0 4m